Ng-click not working inside .ion-search bar

I can’t get ng-click to work on the clear button in the ion-search bar I’ve created. You can see my problem in the forked codepen here.

When clicking on the circled x in the search bar, I should get a message in the console. Is the search bar preventing the click event or something?

So you have two problems with this:

  1. For some reason ng-click does not fire when it’s inside of a label tag, changing it to a div works. I’ve run into this multiple times.

     <div class="item-input-wrapper" id="search-input">
  2. Directly calling the console.log within the ng-click doesn’t work. Changing it to call a function that does a console log works, as well as changing it to

     <i class="icon ion-close-circled placeholder-icon" ng-click="query = ''"></i>

Ha! Thanks so much! It’s been driving me crazy. Works like a charm.

1 Like