I am trying to have angular look at the $viewValue controller from inside the directive.
script: http://jsfiddle.net/dkrotts/TfTr5/5/
function foo($scope, $timeout) { $scope.bar = "Lorem ipsum"; $timeout(function() { $scope.bar = "Dolor sit amet"; }, 2000); } myApp.directive('myDirective', function() { return { restrict: 'A', require: '?ngModel', link: function (scope, element, attrs, controller) { scope.$watch(controller.$viewValue, function() { console.log("Changed to " + controller.$viewValue); }); } } });
As it is, the $ watch function does not capture the model change made after 2 seconds from the inside of the controller. What am I missing?
angularjs angularjs-directive
Dustin Jan 28 '13 at 17:41 2013-01-28 17:41
source share