Created
October 22, 2014 12:17
-
-
Save jpettersson/8f14fccbcae61d2f55f8 to your computer and use it in GitHub Desktop.
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
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