i have a text field in my html page as below :
<ion-input type="text" (input)="getid($event.target.value)" autofocus="true" id="get_ticket_id"></ion-input>
i want this text field to be sent to blank/empty every time page loads/ user comes to the page by opening application or using back-button
how can i achieve that, i have done lot of search on this but could not find the solution, can someone please advise me how can it be acheieved
Use ngModel, that is one of absolute essentials you should learn about Angular. Also together with ionViewWillEnter() as suggested. So something like this:
ts:
myInput = "";
ionViewWillEnter() {
this.myInput = "";
}
getId(val) {
console.log(val)
}
And the template:
<ion-input [ngModel]="myInput" (ngModelChange)="getId($event)"></ion-input>
So I also suggest to use ngModelChange instead of (input), we are coding with angular :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With