Here is an example of my HTML code:
<input ng-controller="cboxCtrl" type="checkbox"
ng-model="hideCompleted" ng-change="hideChanged()"/>
Here is the corresponding controller code:
angular.module('simple-todos').controller('cboxCtrl', ['$scope',
function ($scope) {
console.log("starting");
$scope.hideChanged = function () {
console.log("in hideChanged() ");
};
}]); // end controller
Everything works well and I can see the message on the console when I click the checkbox. However, if I wrap the checkbox with a label:
<label>
<input ng-controller="cboxCtrl" type="checkbox"
ng-model="hideCompleted" ng-change="hideChanged()"/>
Some text to explain the checkbox
</label>
The ng-change function does not get triggered when I click the checkbox. It seems like a scoping issue, but I'm unsure what exactly is causing it. When I replace labels with divs (even though it affects the layout), the ng-change function works as expected.