I have an array with boolean values and what I need to do is try to use the $watch function in order to show a message when some change happens in the array.
As you can see in this code the array changes its values but the $watch function doesn't work. Any idea?
View
<div data-ng-repeat="catA in categoryA">
<b><input type="checkbox" checked="checked" ng-model="arrayCategoryA[$index]"/>{{catA.name}}</b>
</div>
Controller
app.controller("controllerApp", function($scope, $http, $filter){
$scope.arrayCategoryA = [];
$scope.$watchCollection($scope.arrayCategoryA, function(newVal, oldVal){
console.log("something changed");
}, true);
$http.get("categoryA.json").success(function(data) {
$scope.categoryA = data;
for (var i = 0; i < $scope.categoryA.length; i++)
$scope.arrayCategoryA[i] = true;
});
});