ng-click button inside a label

Asked

Viewed 787 times

1

My intention is for a close-up button to appear inside the input so that by clicking on it, the search query is reassembled and returns all the items again and not just the items of the search in question. This button should disappear while the user does not type again in the search field. It seems that I did everything right, but the ng-click is not working on button within the element label. 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 on the controller:

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

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

  • 1

    Why don’t you use one div instead of label?

  • You saved my job. Thank you Techies.

  • 1

    Not at all @David :p

  • Put the problem solution as the answer if you have solved it.

  • I don’t know how to do it.

  • 1

    press on the "Check" icon below the voting arrow of his reply ;)

Show 1 more comment

1 answer

5


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.