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” 来完成

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值