In AngularJS, I have successfully set up a route with a variable parameter.
This question is an expansion on this previous inquiry; where I was able to utilize params
in a variable templateUrl like this:
.when('/course/:lesson', {
templateUrl: function(params){
return '/partials/course/' + params.lesson;
}
//...
})
However, when attempting to do something similar for a variable controller name, I encountered an unknown provider
error.
.when('/course/:lesson', {
templateUrl: function(params){
return '/partials/course/' + params.lesson;
},
controller: function(params){
return params.lesson + 'Ctrl';
}
})
Essentially, instead of creating numerous routes that all follow the same pattern, I want to dynamically map the lesson
variable to both the /partials/course/{{lesson}}
route and the {{lesson}}Ctrl
controller.
Is this achievable?