Skip to content Skip to sidebar Skip to footer

Angularjs - Passing A Variable Into `$routeprovider`

Trying to figure out an 'Angular specific' way to try and achieve this. I have a page with some views. When a user clicks an anchor, the views change, which I have working just fin

Solution 1:

You can use function for templateUrl to dynamically construct url. This function accepts an object of route parameters:

$routeProvider.
    when('/:nameHolder', {
        templateUrl: function(params) {
            return params.nameHolder + ".html";
        },
        controller: 'individ',
        nameofuser: nameHolder
}).

Post a Comment for "Angularjs - Passing A Variable Into `$routeprovider`"