接触过程序开发的小伙伴们对 MVC 的开发方式想必一点也不陌生,是的, angularjs 所采用的方式即是 MVVM 的开发方式,这里的 controller 即控制器angularjs
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.web
译文:svg
ngController 是关注于视图 controller 的一个指令ui
This directive creates new scope.
This directive executes at priority level 500.
译文:spa
指令会建立一个 scope 即做用域
当咱们须要一个新的模块而且不但愿它跟其余模块的数据产生冲突的状况下,咱们就能够使用一个 ngController 来独立这一块的内容,好比咱们的文章正文模块能够使用 ng-controller=”AricleController”,而文章中的评论模块则能够使用 ng-controller=”CommentController” 来完成code