Skip to content

Instantly share code, notes, and snippets.

@tristanpendergrass
Created October 23, 2014 20:58
Show Gist options
  • Save tristanpendergrass/bed1d51c81d25b2ef726 to your computer and use it in GitHub Desktop.
Save tristanpendergrass/bed1d51c81d25b2ef726 to your computer and use it in GitHub Desktop.
'use strict';
(function () {
var app = angular.module('initializer', [
'ui.router',
'constant',
'ngCookies',
'authService',
'ngRoute'
]);
app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/select/account');
$stateProvider
.state('select', {
url: '/select',
template: 'Why hello there<div ui-view></div>',
resolve: {
login: function (authService, User, $q) {
console.log('resolving login');
if (User.name) return User.getAccounts();
var defer = $q.defer();
authService.getUserInfo().then(function (res) {
User.name = res.data.name;
User.sub = res.data.sub;
User.getAccounts().then(function () {
defer.resolve();
});
});
return defer.promise;
}
}
})
.state('select.account', {
url: '/account',
controller: 'AccountSelectCtr',
controllerAs: 'vm',
templateUrl: 'partials/select.account.html'
})
.state('select.mobileInstance', {
url: '/mobileInstance',
templateUrl: 'partials/select.mobileInstance.html'
});
});
//app.config(['$routeProvider', function ($routeProvider, authService) {
//$routeProvider
//.when('/select', {
//templateUrl: 'partials/select.html',
//controller: 'selectCtr',
//controllerAs: 'vm',
//resolve: {
//login: function (authService) {
//return authService.getUserInfo();
//}
//}
//})
//.otherwise({
//redirectTo: '/select'
//});
//}]);
app.run(function ($rootScope, authService) {
$rootScope.authUrl = '/auth?app=initializer';
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment