angular - 离子输入无法绑定到“errorStateMatcher”
问题描述
我正在尝试将我的一些工作角度代码复制到 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>
解决方案
ErrorStateMatcher 在@angular/material 库中定义。确保添加库并导入必要的模块。
mat-form-field 允许您将错误消息与 matInput 相关联。默认情况下,当控件无效并且用户已与(触摸)元素交互或已提交父表单时,将显示这些错误消息。如果您希望覆盖此行为(例如,在无效控件脏或父表单组无效时立即显示错误),您可以使用 matInput 的 errorStateMatcher 属性
有关更多信息,请参阅:Ionic 4 中的 Angular Material 入门
推荐阅读
- php - 无法在 Laravel 的表结构中设置外键
- matlab - 尝试创建一个 MATLAB 函数,包括一个 while 循环,用于计算一个值的平方根
- python - 为什么连接函数在python中不返回预期的字符串
- python - 从单个数据框中的行中查找数据以在同一数据框中创建新列
- flutter - 在 Flutter 中使用 Provider 依赖
- android - 当 GPS 关闭时,Kotlin allCellInfo 返回 null
- python - Pandas - 用字符串标签替换列表中的 int 值
- python - 是否可以使用 pandas 设置最大字符串长度(如 SQL)
- php - 在 App Engine Standard 上部署 Laravel 6 需要部署的文件过多(超过 10,000 个)
- javascript - 使用 jQuery + FadeOut 更改图像源