1
votes

I am reading here: https://groups.google.com/forum/#!topic/angular/ZcA4eOttQzA

As for knowing when ngModel's value changes, there are two ways I've seen to do it. One is by overriding ngModelController's $render function. Another way, which has proven more reliable in my experience, is to use scope.$watch coupled with a function, as alluded to above. For example:

require: "ngModel", link: function link(scope, element, attrs, ngModelCtrl) { scope.$watch(function () { return scope.$modelValue; }, function (value) { // Do something with updated model value... }); }

I tried this in my code but the only time it fires is at the start. Can someone explain what scope.$modelValue is exactly?

1

1 Answers

2
votes
$modelValue: The value in the model, exposed to your controller.

There are two views of a ngModel data. The $viewValue is the view at DOM. $modelView is what the controller has actual value of the model.