Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear button for input field in ionic2

What is the easy way to add a clear (x) button to an input field in ionic 2? It's supposed to delete the entered content. enter image description here

like image 794
Display Name Avatar asked Aug 04 '17 12:08

Display Name


1 Answers

<ion-item>
  <ion-label>Clear Icon</ion-label>
  <ion-input placeholder="Clear Input" clearInput></ion-input>
</ion-item>

Just add a clearinput attribute to your inputs and it'll show an x button in the right side of input.

There's also a clearOnEdit attribute which clears the input when the user focuses on it again.

Hope this helps

like image 192
Gabriel Barreto Avatar answered Sep 19 '22 21:09

Gabriel Barreto