【发布时间】:2019-02-25 20:53:58
【问题描述】:
众所周知,当我们像 {{ $ctrl.obj }} 这样绑定到模板中的变量时,AngularJS 使用最简单的 $watch 形式。
它应该通过引用比较$ctrl.obj 的值,但是如果我改变$ctrl.obj,则更改会反映在视图中。引用没有改变,为什么?
【问题讨论】:
-
查看我的最新答案。你最后的评论让我意识到我之前的回答是错误的。 BTW,根据source code,
ngBind指令不要使用第三个参数:相关部分是:scope.$watch(attr.ngBind, function ngBindWatchAction(value) { element.textContent = stringify(value); });
标签: angularjs angularjs-watch angularjs-bindings