Reputation: 13616
I have array of objects:
Each object has this properties:
I need to perform some operations when IsNormal
property changes in one of the objects above.
I tried this:
$scope.$watch('inspectionReviews.IsNormal', function () {
//some logic
})
But it doesn't work.
Any idea how I can trigger a function when IsNormal
property of inspectionReviews
object changes?
Upvotes: 0
Views: 71
Reputation: 5627
You can make a deep watch or use watchCollection.
Deep watch:
$scope.$watch('inspectionReviews', function (newVal, oldVal) { /*...*/ }, true);
watchCollection:
$scope.$watchCollection('inspectionReviews', function (newVal, oldVal) { /*...*/ });
However, both of them will call the watch function for every change of the collection.
Upvotes: 1