Both $watch and ngChange have completely different uses:
Suppose you have a model defined in the scope:
$scope.myModel = [ { "foo":"bar" } ];
Now, if you want to do something when any changes happen to myModel , you should use $watch :
$scope.$watch("myModel", function(newValue, oldValue){
ngChange is a directive that evaluates a given expression when a user changes input:
<select ng-model="selectedOption" ng-options="option for option in options" ng-change="myModel=selectedOption"></select>
In short, you usually bind ngChange to some HTML element. While $watch for models.
AlwaysALearner Sep 25 '13 at 14:21 2013-09-25 14:21
source share