Angularjs 中的 controller
生活随笔
收集整理的這篇文章主要介紹了
Angularjs 中的 controller
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
接觸過程序開發的小伙伴們對 MVC 的開發方式想必一點也不陌生,是的, angularjs 所采用的方式便是 MVVM 的開發方式,這里的 controller 即控制器
了解 controller
The ngController directive attaches a controller class to the view. This is a key aspect of how angular supports the principles behind the Model-View-Controller design pattern.
譯文:
ngController 是關注于視圖 controller 的一個指令
指令的基本信息
This directive creates new scope. This directive executes at priority level 500.譯文:
指令會創建一個 scope 即作用域什么時候使用 controller
當我們需要一個新的模塊并且不希望它跟其他模塊的數據產生沖突的情況下,我們就可以使用一個 ngController 來獨立這一塊的內容,比如我們的文章正文模塊可以使用 ng-controller=”AricleController”,而文章中的評論模塊則可以使用 ng-controller=”CommentController” 來完成
總結
以上是生活随笔為你收集整理的Angularjs 中的 controller的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常用的 WEB 服务器
- 下一篇: 开始学习一个指令 directive 并