我遇到了与重置表单有关的问题:
我的表单就像:
单击“取消”按钮时:
let cancelClick$ = Observable
.fromEvent(
this.cancelButton.nativeElement,
'click'
);
const cleanUser = () => map(() => <AdministrationUser>{
id: "id",
fatherName: "father",
motherName: "mother",
name: "name",
startDate: null,
suspendDate: null
});
const resetForm = () => tap((user) => this.userForm.reset(user));
cancelClick$.pipe(cleanUser(), resetForm());
但是,当单击“取消”按钮时,NIF
表单字段被填充到null
或empty
...另一个字段被正确填充。
我相关的表单字段html代码是:
<input id="nif" name="nif" class="form-control" [(ngModel)]="user.id"...>
有什么想法吗?