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){
                //...
});

 

posted @ 2020-12-03 16:48  用脑袋行走的人  阅读(2752)  评论(0编辑  收藏  举报