AngularJS ui-router, how to get the name of the targeted state in the resolve object of an abstract partent state? -
AngularJS ui-router, how to get the name of the targeted state in the resolve object of an abstract partent state? -
i using ui-router , have kid states , abstract 1 - parent.
now, want able user role management , want in single place, roots.
the best way it, in parent's state resolve object.$stateprovider
here, mange app width authentication data.
the question is, how targeted state resolve function of abstract state?
.state('section', { abstract: true, template: '<ui-view/>', resolve: { // auth & role management middleware. userdata: ['$q', '$stateparams', 'session', function ($q, $stateparams, session) { // how destination route here. $state.current.name - returns null $stateparams - empty object. // ideas? var userdata; userdata = session.getuserdata(); if (userdata.token) { homecoming userdata; } homecoming $q.reject('login'); }] } });
state hasn't updated when within resolve.
my workaround far hear '$statechangestart' event by
$rootscope.$on('$statechangestart', callback)
this event emitted before resolve, , sec param passed callback tostate
has info need.
you can set logic session service
angularjs
Comments
Post a Comment