angularjs – 观察多个$scope属性
发布时间:2020-12-17 09:30:36 所属栏目:安全 来源:网络整理
导读:有没有办法订阅多个对象使用$ watch的事件 例如。 $scope.$watch('item1,item2',function () { }); 从AngularJS 1.3开始,有一个称为 $watchGroup 的新方法来观察一组表达式。 $scope.foo = 'foo';$scope.bar = 'bar';$scope.$watchGroup(['foo','bar'],func
有没有办法订阅多个对象使用$ watch的事件 例如。 $scope.$watch('item1,item2',function () { }); 从AngularJS 1.3开始,有一个称为 $scope.foo = 'foo'; $scope.bar = 'bar'; $scope.$watchGroup(['foo','bar'],function(newValues,oldValues,scope) { // newValues array contains the current values of the watch expressions // with the indexes matching those of the watchExpression array // i.e. // newValues[0] -> $scope.foo // and // newValues[1] -> $scope.bar }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读