0

I have a small question regarding scopes and promises. I declared wiz_ids outside a promise call and I would like to access it again when the promise is resolved. I tried to use bind() but without luck.

This is my state:

state: 'wizard',
config: {

    url: '/wizard',
    templateUrl: 'app/partners/wizard/wizard.html',
    controller: 'WizardController',
    controllerAs: 'vm',
    redirectTo: 'wizard.step1',
    resolve: {
        /* @ngInject */
        promiseData: ['$window', '$location', 'WizardDataService',  function ($window, $location, WizardDataService) {
                var wiz_ids = {
                    'wiz_install_id': $location.search().install_id,
                    'wiz_instance_id': $location.search().instance_id
                };

                return WizardDataService.getWizardData(wiz_ids)
                    .then(function (response) {
                       // How do I access wiz_ids from here? //
                        return response.data;
                    });
            }]
    },
}
1
  • Can you show wizard.step1 state config ? Commented Nov 27, 2016 at 14:16

1 Answer 1

2

You could return a more complex object inside then().

Something like:

return WizardDataService.getWizardData(wiz_ids)
  .then(function(response) {

    var data = {
      wiz_ids: wiz_ids,
      wiz_data: response.data
    }

    return data;
  });

Then in controller access the individual properties accordingly

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.