请看这个小提琴:
scope.$watch('points', function (value) {
scope.console.push('scope.$watch');
});
出于某种原因,$scope.points
更改
$scope.points.push(1);
为什么?
编辑澄清:
我希望看到这个:
events: ["scope.$watch","testUpdate()","scope.$watch","testUpdate()","scope.$watch","testUpdate()"]
但相反,我看到了这一点:
events: ["scope.$watch","testUpdate()","testUpdate()","testUpdate()"]
请注意缺少scope.$watch
es
答案 0 :(得分:3)
好的,在属性函数watch中添加true:
scope.$watch('points', function (value) {
alert('totowatch');
scope.console.push('scope.$watch');
},true);