我不知道如何处理此错误:
Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'NgModel' since it isn't a known property of 'ion-input'.
1. If 'ion-input' is an Angular component and it has 'NgModel' 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. ("
<ion-item>
<ion-label>Cambio</ion-label>
<ion-input type="text" [ERROR ->][(NgModel)]="item.cambio" placeholder="e.g:"></ion-input>
</ion-item>
在导入时,我也有以下代码:
imports: [
...,
IonicModule.forRoot(MyApp),
...
我在Udemy上关注此course,但没有有关此问题的任何信息
答案 0 :(得分:6)
如果您正在使用[(ngModel)]
并仍然遇到此错误,请不要忘记在当前模块中导入FormsModule
答案 1 :(得分:4)
您正在使用:
[(NgModel)]="item.cambio"
何时应使用:
[(ngModel)]="item.cambio"
像这样更改您的模板代码:
<ion-item>
<ion-label>Cambio</ion-label>
<ion-input type="text" [(ngModel)]="item.cambio" placeholder="e.g:"></ion-input>
</ion-item>