aus*_*tin 13 javascript angularjs angularjs-directive angularjs-routing
我在AngularJS网站上完成了教程,我注意到在第7步,它们改变了控制器如何引入应用程序.最初,他们使用指令:
<body ng-controller="PhoneListCtrl">
...
</body>
Run Code Online (Sandbox Code Playgroud)
但是,它稍后会更改为使用controller属性作为一部分ng-route.
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
/* rest of routes here */
Run Code Online (Sandbox Code Playgroud)
这是进行更改的git diff.这两种技术有区别吗?
控制器使用ng-controller指令:
ng-controller元素上创建一个新的$ scope .路线中的控制器:
ng-view元素上为每个路径创建一个新的$ scope .| 归档时间: |
|
| 查看次数: |
3928 次 |
| 最近记录: |