'ngModel does not work on modal page in Ionic 6
I am developing an Ionic/Angular app and wanted to use ngModel as alwayls. I am opening a modal from a modal and then want to use it like:
<ion-list>
<ion-item>
<ion-label position="stacked">Name des Rezepts</ion-label>
<ion-input [(ngModel)]="model" ></ion-input>
</ion-item>
</ion-list>
<ion-button (click)="save()">Save</ion-button>
i declared the variable in typescript like:
public model="";
But when i click save, my output IS ALWAYS the empty string?!
I imported ReactiveFormsModule in my app.module.ts and on normal pages it works, but in modals it seems like that it does not work?!
Do you guys have any ideas? Thank you!
Solution 1:[1]
You take a look at this example ( same as yours ) https://stackblitz.com/edit/ionic-angular-v5-mqyzyh?file=src%2Fapp%2Fapp.component.html it works as expected. So check your imports in your module ( but without modules you'll get an error anyway ). Out of topic, you don't need 2 way binding. You're updating the value from the input ( at least in this example ).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Yozmo |