Is there a more efficient way to handle routing in AngularJS, specifically for loading html templates based on $location.path? My current approach involves a long list of "Whens" that will become unmanageable as my application grows.
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
//Home
//User/Tenant/Register
when('/register', { templateUrl: 'pages/Auth/register.html' }).
when('/login', { templateUrl: 'pages/Auth/login.html' }).
//User
when('/user', { templateUrl: 'pages/User/list.html' }).
when('/user/new', { templateUrl: 'pages/User/new.html' }).
when('/user/:userId', { templateUrl: 'pages/User/detail.html' }).
when('/user/edit/:userId', { templateUrl: 'pages/User/new.html' }).
//Role
when('/role', { templateUrl: 'pages/Role/list.html' }).
when('/role/new', { templateUrl: 'pages/Role/new.html' }).
when('/role/:roleId', { templateUrl: 'pages/Role/detail.html' }).
when('/role/edit/:roleId', { templateUrl: 'pages/Role/new.html' }).
when('/roleassign', { templateUrl: 'pages/Role/assign.html' }).
when('/roledefine', { templateUrl: 'pages/Role/define.html' }).
//Permissions
when('/permission', { templateUrl: 'pages/Permission/list.html' }).
when('/permission/new', { templateUrl: 'pages/Permission/new.html' }).
when('/permission/:permissionId', { templateUrl: 'pages/Permission/detail.html' }).
when('/permission/edit/:permissionId', { templateUrl: 'pages/Permission/new.html' }).
when('/permissionassign', { templateUrl: 'pages/Permission/assign.html' }).
//Counter
when('/X', { templateUrl: 'pages/Counter/list.html' }).
when('/X/new', { templateUrl: 'pages/Counter/new.html' }).
when('/X/:counterId', { templateUrl: 'pages/Counter/detail.html' }).
when('/X/edit/:counterId', { templateUrl: 'pages/Counter/new.html' }).
//Company
when('/Y', { templateUrl: 'pages/Y/list.html' }).
when('/Y/new', { templateUrl: 'pages/Y/new.html' }).
when('/Y/:companyId', { templateUrl: 'pages/Y/detail.html' }).
when('/Y/edit/:companyId', { templateUrl: 'pages/Y/new.html' }).
//Product
when('/Z', { templateUrl: 'pages/Z/list.html' }).
when('/Z/new', { templateUrl: 'pages/Z/new.html' }).
when('/Z/:productId', { templateUrl: 'pages/Z/detail.html' }).
when('/Z/edit/:productId', { templateUrl: 'pages/Z/new.html' }).
otherwise({
redirectTo: '/index',
templateUrl: 'pages/dashboard.html'
});
//$locationProvider.html5Mode(true);
}])