Reputation: 377
Is it possible to use the route parameters as part of the route?
E.g.
when('/static/:dynamic', {
templateUrl: 'partials/static/:dynamic.html',
controller: 'staticController'
})
I don't need a dynamic controller. I only need that the URL is resolved dynamically.
Upvotes: 1
Views: 308
Reputation: 377
I already found a proper solution.
You can put a function into the templateUrl:
when('/static/:dynamic', {
templateUrl: function(urlattr){
return urlattr.dynamic + '.html';
},
controller: 'staticController'
})
Its also possible to put a * into the route, which allows you to get the whole path as one string:
when('/:dynamic*', {
templateUrl: function(urlattr){
return urlattr.dynamic + '.html';
},
controller: 'staticController'
})
With that solution you can use "localhost:13370/app/index.html#/static/dynamic/random" as URL and get "static/dynamic/random" as string in urlattr.dynamic.
Upvotes: 1