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
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
1 Comment
Will Keeling
Worth mentioning that this approach also works for accordions - where you have a checkbox present in the accordion heading.