$watch 绑定就加监视,再就是$watch手工监视
$watch with true(deep equality)
|
|
type of watches
every scope will have its own watch list, including root scope
下图中c的watcher listener修改了a的值引起第二轮digest
digest process democode
|
|
console output: second level watch actually look like this in ng1.5.8
- 原来是因为c在a后面只触发了一次, 视频里是c修改a,所以触发了两次囧
|
|
digest and angular context
- 这就是手写jsonp服务不能触发digest的原因, 因为是在js runtime而不是angular runtime执行的代码
需要manually invoke $apply or $digest
$apply vs $digest
- $apply calls $digest
- $apply just $digest call on $rootScope
- ng-click will call $apply
demo $apply vs $digest
在控制台选择
ng-ctroller-scope
修改pai的内容, 如angular.element($0).scope().$parent.pai[3]=3.13145
调用
angular.element($0).scope().$digest()
, 只会刷新ng-ctroller-scope
的内容,因为ng-repeat
创建了另外的4个同级scope
|
|