var app = angular.module('application', [ 'ngRoute', 'ui.bootstrap' ]);
// configure our routes
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'assets/views/home.php',
controller : 'HomeCtrl'
})
// route for the home page
.when('/dev', {
templateUrl : 'assets/views/dev.php',
controller : 'devCtrl'
})
// route for the home page
.when('/dev/:id', {
templateUrl : 'assets/views/dev.php',
controller : 'devCtrl'
});
});
app.run(function($rootScope, $window, $location, $route, $templateCache) {
$rootScope.$on('$routeChangeStart', function() {
});
});
我使用上面的角度来路由我的页面。我正在尝试访问带有参数的URL,而我所获得的只是一个白页。 http://domain.com/dev/1234
我错过了什么吗?
答案 0 :(得分:0)
事实证明我需要在/
templateUrl
console.log错误显示它正在尝试再次加载角度。
var app = angular.module('application', [ 'ngRoute', 'ui.bootstrap' ]);
// configure our routes
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
// route for the home page
.when('/', {
templateUrl : '/assets/views/home.php',
controller : 'HomeCtrl'
})
// route for the home page
.when('/dev', {
templateUrl : '/assets/views/dev.php',
controller : 'devCtrl'
})
// route for the home page
.when('/dev/:id', {
templateUrl : '/assets/views/dev.php',
controller : 'devCtrl'
});
});
app.run(function($rootScope, $window, $location, $route, $templateCache) {
$rootScope.$on('$routeChangeStart', function() {
});
});