I use ui-router, and I have child states, and the abstract one is parent.
Now I want to be able to manage the user role, and I want to do it in one place, for all the roots.
The best way to do this is in the parent state resolution object. $ stateProvider
Here I am doing this in order to process the authentication width of the application.
The question is how to get the target state from the resolution function of the abstract state?
.state('section', { abstract: true, template: '<ui-view/>', resolve: { // Auth & role management middleware. UserData: ['$q', '$stateParams', 'Session', function ($q, $stateParams, Session) { // HOW DO I GET THE DESTINATION ROUTE HERE. $state.current.name - returns null $stateParams - is an empty object. // ANY IDEAS? var userData; userData = Session.getUserData(); if (userData.token) { return userData; } return $q.reject('login'); }] } });
source share