Last active
August 29, 2015 14:25
-
-
Save Robinyo/63c231ccde4ff7ffadc9 to your computer and use it in GitHub Desktop.
Setting up the application's routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
.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