Startin out with angularjs this issue has puzzled me.
howcome and how can I make sure that when the watch function runs 2nd time (on init) testValue is "changed".
<div ng-controller="MyCtrl"></div>
and js :
var myApp = angular.module('myApp',[]);
function MyCtrl ($scope) {
var testValue = null;
$scope.watchMe = null;
$scope.$watch('watchMe', function () {
console.log('testValue is', testValue);
if(testValue !== null){`enter code here`
console.log('i want to do something different the 2nd time this code runs - but i never get in here...');
}
testValue ="changed";
});
};
And then there is the fiddle : jsfiddle example of the code
Thank you very much