1

I have a table where each row has a checkbox. The table-row listen to ng-click and the checkbox to ng-change:

<tr ng-repeat="box in boxList | box_expect:searchText" ng-click="openBox(box._id)">
    <td>...</td>
    <td>...</td>
    <td>...</td>
    <td><input type="checkbox" ng-change="checkBoxChanged(id)" ...></td>
</tr>

Everytime I click the checkbox, I trigger the ng-click event of the table row.

I changed ng-click to ng-doubleClick, but double-clicks on mobile devices are not comfortable to handle.

How can I fix this?

2
  • Considering angular-touch ? Commented Apr 2, 2014 at 9:17
  • I just want to keep my one-click event. I just want to konw, how can i prevent, that the check-box change event triggers the row ng-click event. Commented Apr 2, 2014 at 9:20

1 Answer 1

3

You can create a directive which stops propagation of the click event on your checkbox (DEMO).

app.directive('noclick', [function() {
    return {
      restrict: 'A',
      link: function link(scope, element, attrs) {
        element.bind('click', function(e) {
            e.stopPropagation();
        });
      }
    }
}]);

And add it to your checkbox:

<input type="checkbox" ng-change="checkBoxChanged(id)" ng-model="loremIpsum" noclick>
Sign up to request clarification or add additional context in comments.

2 Comments

That looks great, I'll implement this and check if it works for me :)
Yes that's it. I would never have thought of a directive for that. Tyvm ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.