如何组织以下代码,使我只能获取 template.html 而不能获取 template1.html?
App.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$routeProvider
.when('/', {
templateUrl: "template/home.html",
controller: "homeCtrl"
})
.when('/artist', {
templateUrl: "template/artist.html",
controller: "artistCtrl"
})
.when('/:collectionId', {
templateUrl: "template/template.html",
controller: "templateCtrl"
})
.when('/:trackId', {
templateUrl: "template/template1.html",
controller: "templateCtrl"
})
.otherwise({
redirectTo: "/"
});
}]);
感谢您的帮助!
最佳答案
您应该重命名您的路线。
.when('/collection:id', {
templateUrl: 'your/template.html',
controller: 'yourController'
});
})
关于javascript - Angular 中的路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40792951/