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.
Asked
Active
Viewed 5,691 times
6

Display Name
- 4,502
- 2
- 47
- 63
1 Answers
17
<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

Sébastien
- 11,860
- 11
- 58
- 78

Gabriel Barreto
- 6,411
- 2
- 24
- 47
-
1Nice! I was not aware of this. +1 – sebaferreras Aug 04 '17 at 13:25
-
Works perfect as of **Feb 2020**, using **Ionic 5**. Thanks a ton for sharing! – Devner Feb 25 '20 at 15:24