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 orngClick
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.
最新评论
大哥资深网民啊,01年我还在念小学。。
看着有点难过。。。
嘿嘿,谢谢老哥,也祝老哥事业蒸蒸日上。
我是你唯一的药学类友情链接网站。 作为一个80后的过来人祝福你,生活越来越好。
这篇文章,我们中学那会老师课堂上念给我们听的。
哈哈哈哈哈,没想到啊, 我有手抄版
嗯,是的
好心办坏事多了去啦
哈哈,是的,我15年末来上海写代码了,一晃三年多过去了,好快。
今天看QQ好友的时候突然看到了你的名字,想起几年前在药品国际注册群挺活跃/厉害的你,现在不见踪影了。就搜了一下,没想到你现在转行去写代码了... (刚才打漏了一句话...)