angular如何知道爲包含'ng-view'元素的模板視圖發出請求?Angular Routing&ng-view
如果我在我的應用程序導航直接說
http://localhost/Categories/List/accessories
。仍然會對'/或索引模板'發出請求,因爲它包含呈現所有視圖所需的'ng-view'元素。
當我從索引導航到/ Categories/List/accessories時,再次請求索引。
下面是我已在部分複製從角MVC「菜譜」的例子在GitHub上
angular.module('myApp', ['myApp.ctrl.list'])
.config(['$routeProvider', '$locationProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/Home/Splash',
});
$routeProvider.when('/Categories/List/:slug', {
templateUrl: '/Categories/List',
controller: 'listCtrl',
});
$routeProvider.otherwise({
redirectTo: '/'
});
}]);
templateUrl通常會包含路徑.html文件。它是否缺少擴展名? – Ketan