In my Angular 1.3 project, I am exploring the concept of dynamic routing. This approach is similar to what has been discussed in articles like this one and here. The examples provided suggest configuring routes like this:
$routeProvider.when('/:group/:pagename', {
controller: 'RouteCtrl',
templateUrl: 'uirouter.html'
})
In this configuration, the controller can access the values of 'group' and 'pagename' through $routeParams, which functions as expected.
Now, I want to enhance this dynamic routing setup by selecting templates and controllers dynamically as well:
$routeProvider.when('/:group/:pagename', {
controller: $routeParams.group + 'Ctrl',
templateUrl: $routeParams.pagename + '.html'
})
While examining the code, I can see that there is a $get property with a function containing $routeParams as a parameter. However, I am struggling to extract and utilize its values effectively.
At this stage of the project, which is still in its infancy, I am open to using either ui-router or ng-router if either of them offers the functionality I am looking for.