Closed
Description
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
:
ui-router/src/state/stateService.ts
Lines 277 to 283 in e7a3481
// 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:
ui-router/src/state/hooks/transitionManager.ts
Lines 108 to 110 in e7a3481
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.