I have two arrays in my application I would like to observe changes:
$scope.a = [{id: 1, text: 'test a - 1'}, ...];
$scope.b = [{id: 1, text: 'test b - 1'}, ...];
function changed(){
// notify application about changes in a or b
}
I have to call the changed()
function when a
or b
have been changed.
$scope.$watchCollection('a', changed);
$scope.$watchCollection('b', changed);
The changed()
callback will be triggered twice if I have changes in a
and b
as well as on init step. I would like to combine two watches in one, something like this:
$scope.$watchCollection('a, b', changed);
How can I do this with Angular?