angularjs - Angular UI-Router state resolve depending on another resolve -
edit: works, problem coming else.
i struggling edge-case scenario, basically:
$stateprovider.state('mystate', { resolve:{ resolvea: function($q){ return $q.when('whatever'); }, resolveb: function(resolvea){ return fetchsomethingbasedon(resolvea); } } ); this not work resolvea can't injected in resolveb function.
there few options considered rejected:
- make resolvea returned value object
{resolvea, resolveb}. discarded because have many side effects on existing controllers. - handle resolveb behaviour @
controllerlevel. discarded because state abstract high level one, don't wan't change childrenstates/controllers
ui-router nested resolve doesn't work on same state, should work on nested states. can access resolved objects parent state.
$stateprovider .state('parent', { resolve:{ resolvea: function($q){ return $q.when('whatever'); } } ) .state('parent.child', { resolve:{ resolveb: function(resolvea){ return fetchsomethingbasedon(resolvea); } } );
Comments
Post a Comment