I am currently researching whether I can achieve the functionality described in the title. Here are my initial thoughts:
Let's consider the following routes I have set up:
.when('/', {
templateUrl : 'partials/homepage.html',
})
.when('/test', {
templateUrl : 'partials/test.html',
})
.when('/page/:pageID', {
templateUrl : 'partials/page.html',
})
.when('/page/single/:pageID', {
templateUrl : 'partials/page-single.html',
})
Previously, I was able to include both the templateUrl and controller details in each route, which worked perfectly fine.
However, the application has been updated so that there is now only one controller containing all necessary information, and this single controller must be retained. The new routes will look something like this:
.when('/:templateName/:pageID', {
controller: 'myCtrl'
})
Is it possible for me to dynamically set the template ID from the controller by extracting the templateName parameter? Additionally, how can I handle cases such as /page/single/:pageID where there is a secondary option in the route?
While I can retrieve the templateName parameter and track changes using the $routeChangeSuccess method, I have not found a way to dynamically set the template on the fly.
Any suggestions or ideas to address this challenge would be greatly appreciated.