如何在AngularJS中使用$ scope。$ watch和$ scope。$ apply?

断了今生、忘了曾经 提交于 2020-08-10 12:14:01

问题:

I don't understand how to use $scope.$watch and $scope.$apply . 我不明白如何使用$scope.$watch$scope.$apply The official documentation isn't helpful. 官方文档没有帮助。

What I don't understand specifically: 我不明白的是:

  • Are they connected to the DOM? 他们连接到DOM吗?
  • How can I update DOM changes to the model? 如何更新对模型的DOM更改?
  • What is the connection point between them? 它们之间的连接点是什么?

I tried this tutorial , but it takes the understanding of $watch and $apply for granted. 我尝试了本教程 ,但需要理解$watch$apply是理所当然的。

What do $apply and $watch do, and how do I use them appropriately? $apply$watch什么作用,如何正确使用它们?


解决方案:

参考一: https://stackoom.com/question/11PTM/如何在AngularJS中使用-scope-watch和-scope-apply
参考二: https://oldbug.net/q/11PTM/How-do-I-use-scope-watch-and-scope-apply-in-AngularJS
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!