I am trying to watch my model value from inside my linking function.
scope.$watch(attrs.ngModel, function() {
console.log("Changed");
});
When I change the model value inside my controller, the $watch function is not triggered.
$scope.myModel = "ACT";
$timeout(function() {
$scope.myModel = "TOTALS";
}, 2000);
Fiddle: http://jsfiddle.net/dkrotts/BtrZH/4/
What am I missing here?
The problem is that you
$watchingattrs.ngModelwhich is equal to “myModel”. You do not have “myModel” bound in your scope. You want to$watch“model”. That is what is bound in the scope of your directive. See http://jsfiddle.net/BtrZH/5/