立诚勿怠,格物致知
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

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

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

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

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册