wonderfan / javascript

Explore the power of HTML,CSS and JavaScript
1 stars 0 forks source link

controller的作用 #60

Closed wonderfan closed 9 years ago

wonderfan commented 9 years ago

controller是view和model之间的桥梁。它的声明是通过module来实现的

wonderfan commented 9 years ago

页面元素的controller 绑定是通过ng-controller directive来实现的

wonderfan commented 9 years ago

当页面被解析和编译的时候,controller的实例会被创建,然后以元素data的形式保存。

wonderfan commented 9 years ago

在controller里面我们需要完成两件事情:

  1. 把模型数据添加到scope中去;
  2. 把处理函数和动作函数添加到scope中去