angularionic3

Can't bind to 'NgModel' since it isn't a known property of 'ion-input'


I don't know how to deal with this error:

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>

On imports, i have this code also:

 imports: [
    ...,
    IonicModule.forRoot(MyApp),
    ...

I'm following this course on Udemy but there isn't any information about this problem


Solution

  • You're using:

    [(NgModel)]="item.cambio"
    

    when you should be using:

    [(ngModel)]="item.cambio"
    

    Change your template code like this:

    <ion-item>
      <ion-label>Cambio</ion-label>
      <ion-input type="text" [(ngModel)]="item.cambio" placeholder="e.g:"></ion-input>
    </ion-item>