In the answer to Databinding in angularjs, @misko-hevery mentioned
'Suppose you have two arrays which need to be kept in sync for whatever reason, ...'.
I have a simliar problem. Say I have two arrays: knives
and forks
. I want to change them and fire only one event and update the UI only once. The sample code is here(http://jsbin.com/efolag/3/edit).
I copied the javascript code here:
var app = angular.module('app',[]);
function Main($scope){
console.log("initialize controller Main");
$scope.value="a";
$scope.$watch("newItem",function(newValue){
$scope.knives=["a","b","c", newValue];
$scope.forks=["d","e","f", newValue];
});
}
My question is how many dirty checking loops will the changes to knives and forks trigger? If it is more than once, is it possible to make it fire only once?