Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0 alpha redirectTo example not working #2450

Closed
temka1234 opened this issue Jan 9, 2016 · 7 comments
Closed

1.0 alpha redirectTo example not working #2450

temka1234 opened this issue Jan 9, 2016 · 7 comments

Comments

@temka1234
Copy link

I am using "1.0.0alpha0" version of ui-router and example with redirectTo not working.

Code inside config of base module:

$transitionsProvider.onStart({
  to: function(state) {
    return state.redirectTo;
  }
}, function($transition$, $state) {
  var targetState = $state.target($transition$.to().redirectTo);
  return $transition$.redirect(targetState);
})

There is no errors in console, log inside callback function works.

If return $transition$.redirect(targetState); replace with return targetState; than transition works fine (without url changing).

@nateabele
Copy link
Contributor

Can you post your state definition?

@temka1234
Copy link
Author

Plunker example http://plnkr.co/edit/Jy7jQT?p=preview

@christopherthielen
Copy link
Contributor

Hi @temka1234
We made some last minute changes to redirect from transition hooks. The $transition$.redirect function is no longer necessary, and will be removed in alpha 1. As you noted, you can simply return the TargetState from the transition hook to redirect the transition.

@temka1234
Copy link
Author

@christopherthielen, Thanks for the reply!

Can you help with few questions related ui-router-extras

  • How to get previous and rejected state after transition finish? Should i use $previousState from ui-router-extras? In code of ui-router-1.0 i see previous method but it used only with $transition$.redirect
  • What functionality from ui-router-extras will deprecated with ui-router 1.0?

@nateabele
Copy link
Contributor

If a transition is redirected, you can access it through $transition$.previous(). It also has from() and to(), and is available for injection in most (all?) hooks.

@christopherthielen
Copy link
Contributor

@temka1234 can you explain to me in more detail what you mean about previous and rejected state after transition finish?

Using your example as as starting point, in which context do you mean "previous and rejected state after transition finish"?

$transitionsProvider.onStart({
  to: function(state) {
    return state.redirectTo;
  }
}, function($transition$, $state) {
  return $state.target($transition$.to().redirectTo);
})

@eddiemonge
Copy link
Contributor

Closing as the original issue seems resolved and this is now just follow up questions on different things. If that is not correct, I can re-open this.

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

No branches or pull requests

4 participants