2016-11-24 131 views
1

如何以一种我只能获取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: "/" 
    }); 
}]); 

谢谢你的帮忙!

+3

您的问题不清楚 – Sajeetharan

+1

改为使用''/ collection /:id''和''/ track /:id''作为路径。 – Svenskunganka

回答

1

您应该重命名您的路线。

.when('/collection:id', { 
    templateUrl: 'your/template.html', 
    controller: 'yourController' 
    }); 
})