Skip to content

Instantly share code, notes, and snippets.

@Robinyo
Last active August 29, 2015 14:25
Show Gist options
  • Save Robinyo/63c231ccde4ff7ffadc9 to your computer and use it in GitHub Desktop.
Save Robinyo/63c231ccde4ff7ffadc9 to your computer and use it in GitHub Desktop.
Setting up the application's routes
...
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '/app',
templateUrl: 'templates/side-menu-template.html',
controller: 'SideMenuController',
abstract: true
})
.state('app.main', {
url: '/main',
views: {
'menuContent': {
templateUrl: 'templates/main-template.html',
controller: 'MainController',
resolve: {
posts: function(PostsService) {
return PostsService.findPosts();
}
}
}
}
})
.state('app.preview', {
url: '/preview/:postId',
views: {
'menuContent': {
templateUrl: 'templates/preview-template.html',
controller: 'PreviewController',
resolve: {
post: function($stateParams, PostsService) {
return PostsService.findPostById($stateParams.postId);
}
}
}
}
})
.state('app.editor', {
url: '/editor/:postId',
views: {
'menuContent': {
templateUrl: 'templates/editor-template.html',
controller: 'EditorController',
resolve: {
post: function($stateParams, PostsService) {
return PostsService.findPostById($stateParams.postId);
}
}
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/main');
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment