web-dev-qa-db-fra.com

Ionic 4 - Ionic Liaison bidirectionnelle d'entrée

En Ionic 4 comment faites-vous la liaison bidirectionnelle. En Ionic 3 je ferais ce qui suit:

<ion-item color="light"> <ion-input type="string" placeholder="Username" [(ngModel)]="username"></ion-input> </ion-item>

Cependant, dans Ionic 4, j'obtiens l'erreur suivante:

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. ("d>
          <ion-item color="light">
              <ion-input type="string" placeholder="Username" [ERROR ->][(ngModel)]="username"></ion-input>
          </ion-item>
          <ion-item color="light">
"): ng:///AppModule/LoginPage.html@12:62

Comment puis-je faire fonctionner cela dans Ionic 4?

6
Ka Tech

Il vous suffit d'importer FormsModule dans app.module.ts . Comme j'ai déjà donné la réponse en détail. Visitez le lien pour plus de détails https://stackoverflow.com/a/55684045/7983887

1
Tahseen Quraishi