Created
January 30, 2015 22:21
-
-
Save DevinClark/c0da91b89b14c21bfc06 to your computer and use it in GitHub Desktop.
ui-router
This file contains hidden or 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
$stateProvider | |
.state({ | |
name: 'root', | |
url: '', | |
abstract: true, | |
templateUrl: '/templates/root.html', | |
controller: 'MainController', | |
controllerAs: 'Main', | |
resolve: { | |
token: function ($q, Auth) { | |
return $q.when(Auth.decodeToken()); | |
}, | |
user: function(token, User) { | |
return User.getUser(token.user_id).then(function (user) { | |
return user[0]; | |
}); | |
} | |
} | |
}) | |
.state({ | |
name: 'root.index', | |
url: '/', | |
templateUrl: '/templates/dashboard.html', | |
controller: 'DashboardController', | |
controllerAs: 'Dashboard', | |
resolve: { | |
products: function (user, Company) { | |
return Company.getProducts(user.company[0].id); | |
} | |
} | |
}) | |
.state({ | |
name: 'login', | |
url: '/login', | |
templateUrl: '/templates/login.html', | |
controller: 'LoginController', | |
controllerAs: 'Login' | |
}) | |
.state({ | |
name: 'logout', | |
url: '/logout', | |
controller: 'LogoutController' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment