【发布时间】:2014-02-21 10:06:31
【问题描述】:
我研究了tutorial on the AngularJS website,我注意到在step 7,它们改变了将控制器引入应用程序的方式。最初,他们使用指令:
<body ng-controller="PhoneListCtrl">
...
</body>
但是,它后来被更改为使用 controller 属性作为 ng-route 的一部分。
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
/* rest of routes here */
这是进行更改的git diff。这两种技术有区别吗?
【问题讨论】:
-
您所在步骤的链接是什么?
-
@qwertynl 第 7 步。docs.angularjs.org/tutorial/step_07
-
@DanDascalescu 我想我的问题是第一位的。
-
@austin:我知道,但不幸的是另一个有更好的答案。
标签: javascript angularjs angularjs-directive angularjs-routing