Search code examples
javascriptjqueryhtmlangularjsangularjs-ng-click

How to prevent ng-click's triggering twice on label tag?


Angular's ng-click gets triggered twice when I click label which has input inside in it. I've tried $event.stopPropagation(); but didn't work. How do I solve this?

I've checked this question also: Angular.js ng-click events on labels are firing twice

<div class="list-group-item" ng-repeat="item in model.data">
  <form role="form" name="selectForm" novalidate>
    <label ng-click="$event.stopPropagation(); updateSelected();">
      <input type="checkbox" ng-model="chechkedSkins[item.id]" />
      <span>{{item.name}}</span>
    </label>
  </form>
</div>

Solution

  • Use ng-change="updateSelected"

    Use this only on the input since the change is triggered even if you click the label.