Here is an example of my array object.
$scope.arr = [{"A":"a","B":"b"},{"A":"c","B":"d"},{"A":"e","B":"f"},{"A":"g","B":"h"}];
I am looking to trigger a function whenever the value of property "A" changes, specifically to count all instances where "A" has a non-empty value. The following scenarios should trigger this function:
- If the value of "A" changes in a newly added object to the array.
- If an object is removed where the property "A" contains a value.
- If a value is added to an empty "A" in an object.
- If an existing value in "A" is emptied in an object.
I have looked into Angular watch documentation and understand that it may be a possible solution. However, I am struggling with how to watch for the specific property("A") within any object of the array.
Any help on this matter would be greatly appreciated.
If there is no viable solution in Angular, I am also open to alternative solutions using underscore.js.