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

問題:

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

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

  • 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是理所固然的。 app

What do $apply and $watch do, and how do I use them appropriately? $apply$watch什麼做用,如何正確使用它們? this


解決方案:

參考一: 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
相關文章
相關標籤/搜索