离子输入无法绑定到“ errorStateMatcher”

时间:2019-07-24 23:56:03

标签: angular ionic-framework

我试图将一些工作的角度代码复制到Ionic项目中,但出现以下错误。我可以在Ionic中使用ErrorStateMatcher吗?有关如何解决该错误的任何建议?

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'errorStateMatcher' since it isn't a known property of 'ion-input'.
1. If 'ion-input' is an Angular component and it has 'errorStateMatcher' input, then verify that it is part of this module.
2. If 'ion-input' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("="password" [(ngModel)]="passwordConfirm" name="passwordConfirm" formControlName="confirmPassword"  [ERROR ->][errorStateMatcher]="matcher"></ion-input>
            <div *ngFor="let validation of memberValidatio"): ng:///RegisterPageModule/RegisterPage.html@65:125



 <ion-input type="password" [(ngModel)]="passwordConfirm" name="passwordConfirm" formControlName="confirmPassword"  [errorStateMatcher]="matcher"></ion-input>

1 个答案:

答案 0 :(得分:1)

ErrorStateMatcher在@ angular / material库中定义。确保添加了库并导入了必要的模块。

  

mat-form-field允许您将错误消息与您的   matInput。默认情况下,当控件   无效,或者用户与(触摸)了   元素或父表单已提交。如果您想覆盖   此行为(例如,在控件无效时立即显示错误   脏或当父表单组无效时),您可以使用   matInput的errorStateMatcher属性

有关更多信息,请参见:Getting Started with Angular Material in Ionic 4