1

请看这个小提琴:

http://jsfiddle.net/sDnN5/

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.$watches

4

1 回答 1

3

好的,在属性函数 watch 中添加 true :

scope.$watch('points', function (value) {
    alert('totowatch');
    scope.console.push('scope.$watch');
},true);
于 2013-05-06T16:02:25.540 回答