So this is what I am trying to accomplish:
'use strict';
var app = angular.module('myModule', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
redirectTo: '/pages'
})
.when('/pages/:pageName', {
templateUrl: 'views/pages/'+pageName+'html',
controller: 'MainController'
});
});
Basically, I want to use the uri to determine which template is used. Currently I get an error that pageName is not defined which I understand. What would be a different way of doing this? Thanks!
templateUrl can be use as function with returning generated URL. We can manipulate url with passing argument which takes routeParams.
See the example.
Hope this help.
templateUrl
can be a function accepting object of route parameters: