Я создал форму для отправки некоторых данных в бэкэнд, но когда я нажимаю на кнопку отправки, ничего не происходит, вот мой код:
app.component.html :
<form[formGroup]="plcService.form" class="normal-form"
(Submit) = "onSubmit()" >
<mat-grid - list cols = "2" rowHeight = "600px" >
<mat-grid - tile >
<div class="controles-container" >
<input type="hidden" formControlName = "$key" />
<mat-form - field >
<input formControlName="name" matInput placeholder = "Name" />
</mat-form-field>
< mat - form - field >
<input formControlName="age" matInput placeholder = "Age" />
</mat-form-field>
< mat - form - field >
<input formControlName="email" matInput placeholder = "Email" />
</mat-form-field>
< div class="button-row" >
<button mat - raised - button color = "primary" type =
"submit"
(click) = "onSubmit()" >
Save
< /button>
< button mat - raised - button color = "warn"(click) =
"onClear()" >
Clear form
< /button>
< /div>
< /div>
< /mat-grid-tile>
< /mat-grid-list>
< /form>
app.compenent.ts :
onSubmit() {
this.systemService.addSystem(this.system);
}
systemService.ts :
addSystem(system: System): Observable < System > {
return this.http.post<System>(this.endpoint, system, httpOptions).pipe(
tap((system: System) =>
console.log(`Created or updated system w/ id=${system.name}`)
),
catchError(this.handleError<System>('addSystem'))
);
}
system.model :
export class System {
public name: string;
public age: string;
public email: string;
}
Когда я отправляю форму, в консоли я получаю [Object Object], а не объект JSON типа System. есть идеи ?