I have a route to handle creation, modification, view and list of users like this :
angular
.module('abcApp', ['ui.router'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('user.add', {
url: '/mgt/user/add',
templateUrl: 'views/mgt_user/add.html',
controller: 'MgtUserCtrl'
})
.state('user.view', {
url: '/mgt/user/view/:userId',
templateUrl: 'views/mgt_user/view.html',
controller: 'MgtUserCtrl'
})
.state('user.list', {
url: '/mgt/user/list',
templateUrl: 'views/mgt_user/list.html',
controller: 'MgtUserCtrl'
});
});
I want to use one route where I can pass the mode as param and get the right templateUrl:
angular
.module('abcApp', ['ui.router'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('userMangement', {
url: '/mgt/user/:mode/:userId',
templateUrl: 'views/mgt_user/' + $routeParams.mode + '.html',
controller: 'MgtUserCtrl'
});
});
mode can be : view, edit, list.
Is there a way to do this?