$watch is triggered directly after init, why?
angularjs
Solution
On first run both values (`newValue` and `oldValue`) are equal, so you may easily escape it by checking for equality:
$scope.$watch("data_copy", function(newValue, oldValue) {
if(newValue === oldValue){
return;
}
alert("$watch triggered!");
});
PLUNKER
Problem
Why does $watch trigger directly after page load and how can I prevent this? http://jsfiddle.net/dcSRu/2/ ``` function MyCtrl($scope) { // Init scope vars $scope.data_copy = {}; // If data_copy changes... $scope.$watch("data_copy", function(newValue, oldValue) { alert("$watch triggered!"); }, true); } ```