在ngRoute中使用參數並直接訪問URL(不通過站點內部的鏈接)時,不會加載CSS。除/chef/:id
之外,我的所有路線都可以正常工作。我用yeoman的angular generator,我用grunt serve
運行的東西。
這裏是我的路線代碼:
angular
.module('agFrontApp', [
'configuration',
'LocalStorageModule',
'ngCookies',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: '../views/main_view.html',
controller: 'MainCtrl',
controllerAs: 'MainCtrl',
})
.when('/login', {
templateUrl: '../views/login_view.html',
controller: 'LoginCtrl',
controllerAs: 'login',
})
.when('/chefs', {
templateUrl: '../views/chef_list_view.html',
controller: 'ChefListController',
controllerAs: 'chefs',
})
.when('/chef/:id', {
templateUrl: '../views/chef_detail_view.html',
controller: 'ChefDetailController',
controllerAs: 'chef'
})
.when('/receitas', {
templateUrl: '../views/recipe_list_view.html',
controller: 'RecipeListController',
controllerAs: 'recipe'
})
.when('/perfil', {
templateUrl: '../views/perfil_view.html',
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
});
這裏是爲/chef/:id
控制器:
'use strict';
(function() {
function ChefDetailController($routeParams, $scope, $log, Chefs) {
var vm = this;
Chefs.getChef($routeParams.id)
.then(function(data) {
$log.log('success');
})
.fail(function(data) {
$log.log('something went wrong');
});
}
angular.module('agFrontApp')
.controller('ChefDetailController',
[ '$routeParams', '$scope', '$log', 'Chefs', ChefDetailController]);
})();
我在做什麼錯?
編輯:
這裏的chef_detail_view.html:http://pastebin.com/bL5ST01N
我們可以看到,其用於該路由模板代碼 – V31 2014-09-25 14:34:25
好的,這是chef_detail_view.html:http://pastebin.com/bL5ST01N – 2014-09-25 14:53:13
而這裏的index.html的,這裏的模板被加載到:HTTP: //pastebin.com/kzVZX8eE – 2014-09-25 14:54:17