Reputation: 1328
I try to use Date Picker with ionic and I don't know how to clear value in the input.
I want to add a value in the list to represent a "null" value : something like this :
There is my code :
<ion-item>
<ion-label>Année</ion-label>
<ion-datetime [(ngModel)]="year" doneText="Valider" cancelText="Annuler" displayFormat="YYYY"></ion-datetime>
</ion-item>
Upvotes: 2
Views: 2506
Reputation: 4099
You can clear the value on click
of cancel
button (cancelText) instead.
HTML:
<ion-item>
<ion-label>Année</ion-label>
<ion-datetime [(ngModel)]="year" (ionCancel)="clear()" doneText="Valider" cancelText="Annuler" displayFormat="YYYY"></ion-datetime>
</ion-item>
TS:
clear() {
this.year = null;
}
Upvotes: 4