Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Created August 1, 2013 16:51
Show Gist options
  • Select an option

  • Save fnakstad/6133163 to your computer and use it in GitHub Desktop.

Select an option

Save fnakstad/6133163 to your computer and use it in GitHub Desktop.
var routes = [
'/partials': {
accessLevel: access.admin, // Access level for all /partials sub routes
subRoutes: [{
// Full URL: /partials/
'/': {
templateUrl: 'partials/index',
controller: partialsCtrl
},
// Full URL: /partials/hello
'/hello': {
templateUrl: 'partials/hello',
controller: partialsHelloctrl
}
}]
},
'/public': {
accessLevel: access.public, // Access level for all /public subroutes
subRoutes: [{
// Full URL: /public/
'/': {
templateUrl: 'public/index',
controller: publicCtrl
},
// Full URL: /public/hello
'/hello': {
templateUrl: 'public/hello',
controller: publicHelloCtrl
}
}]
}
];
// Register the declared routes
// I use underscore to improve readability
_.each(routes, function(route, rootUrl) {
_.each(route.subRoutes, function(subRoute, subUrl) {
$routeProvider.when(rootUrl + subUrl,
{
templateUrl: subRoute.templateUrl,
controller: subRoute.controller,
access: route.accessLevel
});
});
});
@graphicsxp
Copy link
Copy Markdown

are you not missing curly bracket before '/partials' ? How can you then loop through route.subRoutes ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment