我想在表单上添加反应性表单控件,并触发错误:
多个定制值访问器与具有未指定名称属性的表单控件匹配
一切都分开工作,反应形式验证,mask或matDatepicker,任何一对组合也都可以工作,但是三个一起提示错误。
这是我的代码:
In component.ts
formGroup = new FormGroup({
date: new FormControl()
});
In component.html
<mat-form-field>
<input type="text" matInput [matDatepicker]="date_picker" mask="d0/M0/0000" formControlName="date">
<mat-datepicker-toggle matSuffix [for]="date_picker"></mat-datepicker-toggle>
<mat-datepicker #date_picker></mat-datepicker>
</mat-form-field>
我正在使用:
"@angular/cli": "8.3.19"
"ngx-mask": "8.1.7"
"@angular/material": "8.2.3"
我正在努力解决同一问题。根据此线程,没有解决方案,只有一种解决方法:Error: More than one custom value accessor matches form control with unspecified name attribute
我使用了提到的解决方法,将vanilla-text-mask作为临时(我希望)解决方案,但上述线程没有任何活动,因此...这是解决方法的链接:Use more than one CustomValueAcessor in one Input field
希望有帮助!