ng-click button inside a label

1

My intention is for a close button to appear within input so that by clicking on it, the search query is reassembled and returns all items again and not just those of the search in question. This button should disappear as long as the user does not type again in the search field. It looks like I've done everything right, but ng-click is not working on button within the label element. Look at the code:

<label class="item-input-wrapper">
    <i class="icon ion-ios-search placeholder-icon"></i>
    <input type="search" placeholder="Buscar por Evento" ng-model="busca.evento">
    <button class="button" ng-hide="btnZerar" ng-click="zerar()">
        <i class="ion-ios-close-outline"></i>
    </button>
</label>

And in the controller:

$scope.zerar = function() {
   $scope.btnZerar = true;
   carregaEventosInicio();
};

Note: I am using the Ionic Framework. Can someone help me?

    
asked by anonymous 07.01.2016 / 18:23

1 answer

5

When you use Label it replaces the click of the button, so your button does not work. Change this label to a div that will work.

    
08.01.2016 / 11:07