KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to have angular watch the $viewValue of a controller from inside a directive. fiddle: 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 is, the $watch function is not catching the model change done after 2 seconds from inside the controller. What am I missing?
Tags (comma-separated)
Save Edits
Cancel