Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular

ionic3

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

like image 257
M. Mariscal Avatar asked Nov 29 '18 18:11

M. Mariscal


2 Answers

if you are using [(ngModel)] and still getting this error, don't forget to import FormsModule in the current module

like image 175
Muhammad Awais Avatar answered Oct 05 '22 09:10

Muhammad Awais


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>
like image 42
SiddAjmera Avatar answered Oct 05 '22 09:10

SiddAjmera