Having two arrays with boolean values, I attempted to use the $watchCollection function to trigger a message when changes occur in either array. However, it seems that the function is not working as expected.
To diagnose the issue, please refer to this example
Controller
$scope.arrayCategoryA = [];
$scope.arrayCategoryB = [];
$scope.$watchCollection(['arrayCategoryA', 'arrayCategoryB'], function(newVal, oldVal, scope){
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;
});
$http.get("categoryB.json").success(function(data) {
$scope.categoryB = data;
for (var j = 0; j < $scope.categoryB.length; j++)
$scope.arrayCategoryB[j] = true;
});