角形字段未重置

时间:2019-06-13 08:48:58

标签: angular typescript angular-forms

我遇到了与重置表单有关的问题:

我的表单就像:

enter image description here

单击“取消”按钮时:

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表单字段被填充到nullempty ...另一个字段被正确填充。

enter image description here

我相关的表单字段html代码是:

<input id="nif" name="nif" class="form-control" [(ngModel)]="user.id"...>

有什么想法吗?

0 个答案:

没有答案