angularJS监听数据变化

1、监听一个一个变量的值的变化

...
$scope.storeIns = null; //storeIns定义在$scope下
...
$scope.$watch('storeIns', (n, o) => { //storeIns为变量名称 n为变化后的值;o为变化前的值 //todo something })

2、监听多个变量的值

$scope.$watchGroup(['createDate','source'],function(n,o){
                //...
});
原文地址:https://www.cnblogs.com/planetwithpig/p/14081209.html