O'Reilly logo
  • hao wang thinks this is interesting:

The controller is pretty similar to the link function and has almost the same parameters, except itself. However, the purpose of the controller is totally different. While it is recommended that you use the link to bind events and create behaviors, the controller should be used to create behaviors that will be shared with other directives by means of the require property


Cover of AngularJS Essentials


controller 有点像 link 方法,他们几乎有一样的参数,除了它自己。不过,它们两个的目的是完全不一样的。推广你使用 link 去 bind 事件还有创建行为,controller 可以用来创建要与其它指令分享的行为。