Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Deep State Redirect doesn't respect location:false #342

Open
tinyfly opened this issue Sep 29, 2016 · 1 comment
Open

Deep State Redirect doesn't respect location:false #342

tinyfly opened this issue Sep 29, 2016 · 1 comment

Comments

@tinyfly
Copy link

tinyfly commented Sep 29, 2016

I have location: false set on a lot of my routes through ui-sref-opts or as on option on $state.go(). No matter what I try it the url does indeed change when the redirect is done. Even if I went to that deep state with no url change to begin with. Am I doing something wrong or is this by design?

@christopherthielen
Copy link
Owner

christopherthielen commented Oct 5, 2016

It's not by design. Before ui-router 0.2.16 or so, the options was not available in the $stateChangeStart event, so it wasn't even possible. However, it's certainly possible now.

I'd love a PR to address this. The relevant code is mostly here:

ui-router-extras/src/dsr.js

Lines 105 to 122 in 1a3d7c0

$rootScope.$on("$stateChangeStart", function (event, toState, toParams, fromState, fromParams) {
var cfg = getConfig(toState);
if (ignoreDsr || (computeDeepStateStatus(toState) !== REDIRECT) && !cfg['default']) return;
// We're changing directly to one of the redirect (tab) states.
// Get the DSR key for this state by calculating the DSRParams option
var key = getParamsString(toParams, cfg.params);
var redirect = lastSubstate[toState.name][key] || cfg['default'];
if (!redirect) return;
// we have a last substate recorded
var $dsr$ = { redirect: { state: redirect.state, params: redirect.params}, to: { state: toState.name, params: toParams } };
var result = $injector.invoke(cfg.fn, toState, { $dsr$: $dsr$ });
if (!result) return;
if (result.state) redirect = result;
event.preventDefault();
var redirectParams = getMatchParams(toParams, cfg.params);
$state.go(redirect.state, angular.extend(redirectParams, redirect.params));
});

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

No branches or pull requests

2 participants