Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Promise no longer injected in modals #4309

Closed
matthieusieben opened this issue Aug 30, 2015 · 1 comment
Closed

Promise no longer injected in modals #4309

matthieusieben opened this issue Aug 30, 2015 · 1 comment

Comments

@matthieusieben
Copy link

When using the resolve options in modals, and the value to inject is a promise, it is not injected properly in the controller.

Basically, you are missing an else in the function getResolvePromises:

function getResolvePromises(resolves) {
  var promisesArr = [];
  angular.forEach(resolves, function (value) {
    if (angular.isFunction(value) || angular.isArray(value)) {
      promisesArr.push($q.when($injector.invoke(value)));
    } else if (angular.isString(value)) {
      promisesArr.push($q.when($injector.get(value)));
    }
    // If value is a promise, then what ?
  });
  return promisesArr;
}

I would replace this with

function getResolvePromises(resolves) {
  var promisesArr = [];
  angular.forEach(resolves, function (value) {
    if (angular.isFunction(value) || angular.isArray(value)) {
      promisesArr.push($q.when($injector.invoke(value)));
    } else if (angular.isString(value)) {
      promisesArr.push($q.when($injector.get(value)));
    } else if (angular.isObject(value) && angular.isFunction(value.then)) {
      promisesArr.push(value);
    } else {
      // We may need to push an empty value here since we rely on the order of the element
      // when doing:
      // ctrlLocals[key] = tplAndVars[resolveIter++];
    }
  });
  return promisesArr;
}
@wesleycho
Copy link
Contributor

Thanks for the catch - I have a PR that should fix this up and should make it in master soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants