1

I am using AngularUI's bootstrap library 0.4.0. I want to make a tabset that has checkable header, Plunker demo. However, as you can see, I cannot check the checkbox at all. Any suggestion will be greatly appreciated.

1 Answer 1

5

I think I have figured out a solution, although it may seem a bit hacky.

in the checkbox, I add an extra ng-click attribute to become

<input type="checkbox" ng-click="stopPropagation($event)"/>

According to AngularJS documentation, $event has the event object of the action, here is click. So if we can stop the propagation of the event, we can check the checkbox. In the controller, I add a method stopPropagation as below

$scope.stopPropagation = function(e) {
    // to make sure it is a checkbox
    if (angular.element(e.currentTarget).prop('tagName') === 'INPUT') {
        e.stopPropagation();
    }
}

This is the Plunker Demo

Sign up to request clarification or add additional context in comments.

1 Comment

Worth mentioning that this approach also works for accordions - where you have a checkbox present in the accordion heading.

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.