Skip to content

1.0 during redirect: unable to specify reload option #2537

Closed
@christopherthielen

Description

@christopherthielen

This doesn't work:

$transitions.onStart({ to: 'foo' }, ($state, $transition$) => {
  let options = $transition$.options();
  if (!options.reload) {
    return $state.target($transition$.to(), $transition$.params("to"), extend({}, options, { reload: true }));
  }
});

because reload: true is never processed for a redirection.


We process reload option in state.transitionTo:

// If we're reloading, find the state object to reload from
if (isObject(options.reload) && !(<any>options.reload).name)
throw new Error('Invalid reload state object');
options.reloadState = options.reload === true ? this.$current.path[0] : this.stateRegistry.matcher.find(<any> options.reload, options.relative);
if (options.reload && !options.reloadState)
throw new Error(`No such reload state '${(isString(options.reload) ? options.reload : (<any>options.reload).name)}'`);

    // If we're reloading, find the state object to reload from
    if (isObject(options.reload) && !(<any>options.reload).name)
      throw new Error('Invalid reload state object');
    options.reloadState = options.reload === true ? this.$current.path[0] : this.stateRegistry.matcher.find(<any> options.reload, options.relative);

    if (options.reload && !options.reloadState)
      throw new Error(`No such reload state '${(isString(options.reload) ? options.reload : (<any>options.reload).name)}'`);

... but when we process a redirected transition, we do not call transitionTo. instead, we run the transition directly:

if (error.type === RejectType.SUPERSEDED && error.redirected && error.detail instanceof TargetState) {
return this._redirectMgr(transition.redirect(error.detail)).runTransition();
}

We should process the "reload" logic elsewhere; possibly in $state.target() factory function.

Note: this.$current.path[0] is the implicit root state so we can get it from stateRegistry, not $current.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions