I have a route set up in AngularJS, with a variable parameter.
This is an extension of this question; I can use params
in a variable templateUrl like so:
.when('/course/:lesson', {
templateUrl: function(params){
return '/partials/course/' + params.lesson;
}
//...
})
However, if I try to do something for a variable controller name I get an unknown provider
error
.when('/course/:lesson', {
templateUrl: function(params){
return '/partials/course/' + params.lesson;
},
controller: function(params){
return params.lesson + 'Ctrl';
}
})
Basically, instead of writing 100 different routes which all follow the exact same structure, I want to take whatever the lesson
variable is and map it to the /partials/course/{{lesson}}
route as well as the {{lesson}}Ctrl
controller.
Is this possible?