Is it possible to access the $routeParams object in the $routeProvider declaration?

angularjs

Solution

.when('/phones/:phoneId', {
    controller: 'PhoneDetailCtrl'
    templateUrl: function (params) {
        return 'partials/' + params.phoneId + '.html';
    }
})

Problem

In the following code: ``` phonecatApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', { templateUrl: 'partials/phone-list.html', controller: 'PhoneListCtrl' }). when('/phones/:phoneId', { templateUrl: 'partials/phone-detail.html', controller: 'PhoneDetailCtrl' }). otherwise({ redirectTo: '/phones' }); }]); ``` Is it possible to somehow acces the 'phoneId' value in the templateURL, for example something like this (I know it doesn't work but it's to explain what I'm asking): ``` when('/phones/:phoneId', { templateUrl: 'partials/' + $routeParams.phoneId + '.html', controller: 'PhoneDetailCtrl' }). ``` The aim being to load an HTML file named with the phoneId.

Original source