What is scope.$modelValue in AngularJS?

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?


$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.

链接地址: http://www.djcxy.com/p/77924.html

上一篇: modelValue和viewValue之间的区别

下一篇: AngularJS中的$ modelValue是什么?