> 接觸過程序開發的小伙伴們對 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” 來完成