marklagendijk/ui-router.stateHelper

Is there a way to modify the obj use in stateHelperProvider.state(obj) while in the config?

Closed this issue · 0 comments

I want to be able to modify the object I provide the stateHelperProvider.state(obj).

I have a module like this:


(function() {
    'use strict';
    angular
        .module('myApp', [])
        .config(stateConfig);

    stateConfig.$inject = ['stateConfigObject', 'stateHelperProvider', 'someProvider'];
    function stateConfig(stateConfigObject, stateHelperProvider, someProvider) {


        someProvider.$get().getSomeData().then(function(response) {
             // use the response here to modify the stateConfigObject
        });
            stateHelperProvider.state(stateConfigObject);
    }
})();

I know that if I do that, there will be an a-sync issue and the modified stateConfigObject will not be the correct one passed into the stateHelperProvider in the end.

I've tried using the stateHelperProvider inside someProvider.$get() like so, but still no luck:

someProvider.$get().getSomeData().then(function(response) {
   // use the response here to modify the stateConfigObject
   stateHelperProvider.state(stateConfigObject);
});