我有一个问题,应该是基本问题,但我无法解决....
当我点击提交类型的save
按钮时,我的活动ngSubmit
不会触发。
我粘贴你的代码
MY-form.componant.ts:
export class ProfileFormComponent implements OnInit {
data: any = {libelle: 'test', id=1};
libelle: String;
profilForm: FormGroup;
constructor(
private service: ReflexTableService
) {
}
ngOnInit() {
this.profilForm = new FormGroup({
libelle: new FormControl(this.data.libelle ),
id: new FormControl({ value: this.data.id, disabled: true })
});
}
onSubmit() {
console.log(this.data);
console.log(this.profilForm.value);
}
}
MY-form.componant.html:
<div [formGroup]="profilForm" (ngSubmit)="onSubmit()" novalidate>
<button type="submit" [disabled]="profilForm.pristine" class="btn btn-success">Save</button>
<div class="form-group">
<label class="center-block">Libelle:
<input class="form-control" formControlName="libelle">
</label>
<label class="center-block">Id:
<input class="form-control" formControlName="id">
</label>
</div>
</div>
我的错误在哪里?