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

Promise no longer injected in modals #4309

Closed
@matthieusieben

Description

@matthieusieben

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;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions