You are generating this error when you enter the page.
Error: Uncaught (in promise): TypeError: Can not read property 'name' of undefined TypeError: Can not read property 'name' of undefined at Object.eval [as updateDirectives] (AddmenuComponent.html: 8) at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js: 12613) at checkAndUpdateView (core.es5.js: 12025) at callViewAction (core.es5.js: 12340) at execComponentViewsAction (core.es5.js: 12286) at checkAndUpdateView (core.es5.js: 12031) at callWithDebugContext (core.es5.js: 13013) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.es5.js: 12553) at ViewRef_.webpackJsonp ... / .. / .. / core/@angular/core.es5.js.ViewRef_DetectChanges (core.es5.js: 10122) at RouterOutlet.webpackJsonp ... / .. / .. / router/@angular/router.es5.js.RouterOutlet.activateWith (router.es5.js: 5346) at
I'm finding that the code in the Angle that is giving this problem, I'm able to save normally in Postman .
This is my backend on the wheel file, I did it on Node Express
router.post('/admin-painel/addMenu', controller.postMenu);
This is my Angular service class;
adicionar(menu): Promise<Menu> {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
return this._http.post(this.url+'/admin-painel/addMenu',
JSON.stringify(menu), { headers })
.toPromise()
.then(response => response.json());
}
This is my component class;
salvar(form: FormControl) {
this.menuAdminService.adicionar(this.menu)
.then(() => {
this.notificationService.notify('Você excluiu o menu ${this.menu.name} com sucesso');
form.reset();
})
.catch(ErrorHandler.handlerError)
}
And this is my HTML page;
<div class="col-lg-10">
<h3>{{ title }}</h3>
<form novalidate autocomplete="off" >
<div class="col-sm-12 col-xs-12">
<mt-input-container errorMessage="Campo obrigatório e com 5 caracteres" label="Nome">
<input class="form-control" name="name"
[(ngModel)]="menu.name" required minlength="5"
placeholder="Digite o nome do restaurante" >
</mt-input-container>
</div>
</form>
<div class="row">
<div class="col-xs-12">
<button class="btn btn-success pull-right"
><i class="fa fa-credit-card">
</i> Salvar
</button>
</div>
</div>
</div>