Skip to content

Instantly share code, notes, and snippets.

@jpettersson
Created October 22, 2014 12:17
Show Gist options
  • Save jpettersson/8f14fccbcae61d2f55f8 to your computer and use it in GitHub Desktop.
Save jpettersson/8f14fccbcae61d2f55f8 to your computer and use it in GitHub Desktop.
angular.module('jpettersson.reflect')
.config(function ($urlRouterProvider, $stateProvider) {
// For unmatched routes
$urlRouterProvider.otherwise('/dashboard');
// Application routes
$stateProvider
.state('login', {
url: '/login',
controller: 'LoginCtrl',
templateUrl: '_app/states/login/login.ngt'
})
.state('protected', {
abstract: true,
resolve: {
AuthService: function(AuthService) {
var promise = AuthService.authenticate();
promise.catch(function(error) {
console.log('Not logged in!')
window.location = "/#/login"
});
return promise;
}
},
template: "<ui-view/>"
})
.state('protected.dashboard', {
url: '/dashboard',
controller: 'DashboardCtrl',
templateUrl: '_app/states/dashboard/dashboard.ngt'
})
.state('protected.log', {
url: '/log',
controller: 'LogCtrl',
templateUrl: '_app/states/log/log.ngt'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment