立诚勿怠,格物致知
It's all about connecting the dots

AngularJS: Views and Controllers

Reference: AngularJS in Action.

Understanding how views and controllers work–and more importantly how they relate to each other–is the foundation for understanding AngularJS. Much of the prototype work that we do starts with a simple view and controller, and as we achieve the desired functionality, we’ll start to refactor out the view to directives and the controller to services.

  • A view is the HTML after it has been through the AngularJS compilation process.
  • A controller is responsible for defining methods and properties on scope so that they’re available to the view.
  • Scope in AngularJS is simply a JavaScript object that has some events built into it so that the view and controller can be synchronized. It’s essentially the glue between the view and controller.
  • The new controller-as syntax simplifies our controllers by implicitly assigning the controller instance to the scope itself.
  • When a property is declared on scope, it’s immediately available for binding in the view.
  • When a mehod is declared on scope, it’s available to be called from the view.
  • AngularJS comes with prebuilt directives that you can use to perform operations such as ngRepeat for iterating over a collection and displaying each instance with a template or ngClick for capturing a mouse click and calling a method on the controller.
  • You can use filters to filter out items in a collection in ngRepeat so that you only display a subset of the original array, as you saw in the case of our storyboard columns.
赞(0) 打赏
版权声明:非商业用途转载请注明文章链接,商业用途转载请联系邮箱获取授权。
文章名称:《AngularJS: Views and Controllers》
文章链接:https://www.orzzone.com/angularjs-views-and-controllers.html
商业联系:yakima.public@gmail.com
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

大前端WordPress主题 更专业 更方便

支持快讯、专题、百度收录推送、人机验证、多级分类筛选器,适用于垂直站点、科技博客、个人站,扁平化设计、简洁白色、超多功能配置、会员中心、直达链接、文章图片弹窗、自动缩略图等...

去看看

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册