Olá. no meu projeto já criei vários componentes, mas justo esse está dando problema.
erro no console do browser:
Unhandled Promise rejection: "Failed to load http://localhost:8080/app/product/productform.component.html" ; Zone: <root> ; Task: Promise.then ; Value: "Failed to load http://localhost:8080/app/product/productform.component.html" undefined zone.js:516:13
Object { __zone_symbol__error: Error, fileName: Getter, lineNumber: Getter, columnNumber: Getter, message: Getter, name: Getter, stack: Getter, originalStack: Getter, zoneAwareStack: Getter, toString: createMethodProperty/props[key].value(), 5 more… } zone.js:518:9
tenho varios diretorios: home, product,upload etc.. o diretorio do que ta dando problema se chama "form" que é o formulario de cadastro que estou fazendo
form.component.ts
/**
* Created by guguh on 31/03/2017.
*/
/**
* Created by guguh on 25/03/2017.
*/
import {Component} from '@angular/core';
import {Http, Headers} from '@angular/http';
import {Validators, FormBuilder, FormGroup} from '@angular/forms';
import {ProductComponent} from "../product/product.component";
@Component({
moduleId: module.id,
selector: 'form',
templateUrl: './form.component.html'
})
export class FormComponent {
http: Http;
myForm: FormGroup;
product: ProductComponent = new ProductComponent();
constructor(http: Http, fb: FormBuilder) {
this.http = http;
this.myForm = fb.group({
descricao: ['', Validators.compose([Validators.required])]
});
}
saveProduct(event: any) {
event.preventDefault();
let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http
.post('salvar', JSON.stringify(this.product), {headers: headers})
.subscribe(() => {
console.log('Produto Salvo Com Sucesso!');
this.product = new ProductComponent();
}, error => console.log(error))
}
}
form.component.html
<h1 class="text-center">Cadastro de Fotos</h1>
<div class="container">
<form [formGroup]="meuForm" class="row" (submit)="saveProduct($event)">
<div class="form-group">
<label>Descrição</label>
<input
formControlName="descricao"
name="descricao"
[(ngModel)]="product.descricao"
class="form-control"
autocomplete="off">
<span *ngIf="meuForm.controls.descricao.errors.required" class="form-control alert-danger"><!--se estiver vazio vai mostrar o span -->
Descrição obrigatória
</span>
</div>
<div class="form-group">
<label>Preço</label>
<input
formControlName="valor"
name="valor"
[(ngModel)]="product.valor"
class="form-control"
autocomplete="off">
<span *ngIf="meuForm.controls.descricao.errors.required" class="form-control alert-danger"><!--se estiver vazio vai mostrar o span -->
Preço obrigatório
</span>
</div>
<div class="form-group">
<label>Código de Barras</label>
<input
formControlName="codigoBarra"
name="codigoBarra"
[(ngModel)]="product.codigoBarra"
class="form-control"
autocomplete="off">
<span *ngIf="meuForm.controls.codigoBarra.errors.required" class="form-control alert-danger"><!--se estiver vazio vai mostrar o span -->
Código de barras obrigatório
</span>
</div>
<button [disabled]="meuForm.invalid" type="submit" class="btn btn-primary">
Salvar
</button>
<a [routerLink]="['']" class="btn btn-primary">Voltar</a>
<hr>
</form>
</div>
app.module.ts:
import 'rxjs/add/operator/map';
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
import {routing} from './app.routes';
import {HomeComponent} from './home/home.component';
import {ProductManagerComponent} from './productManager/product-manager.component';
import {HttpModule} from '@angular/http';
import {UploadModule} from './upload/upload.module';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {ProductComponent} from "./product/product.component";
import {FormComponent} from './form/form.component';
@NgModule({
imports: [BrowserModule,
FormsModule,
ReactiveFormsModule,
routing,
HttpModule,
UploadModule
],
declarations: [AppComponent,
HomeComponent,
ProductManagerComponent,
ProductComponent,
FormComponent
],
bootstrap: [AppComponent]
})
export class AppModule {
}
ja tentei de tudo e até agora n consigo ver o erro.....