Clear button for input field in ionic2

时间:2017-08-04 12:03:20

标签: ionic2 input-field

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

1 个答案:

答案 0 :(得分:12)

<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