christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

FutureState: Promise rejected on successful transition (plunkr provided) #338

Closed jdmichaud closed 7 years ago

jdmichaud commented 7 years ago

When calling $state.go('someState'); on a futureState someState, the return promise fails even though the state is properly loaded. It seems to be due to the event.preventDefault(); in $stateNotFound event handler:

* - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or
*   when a `$stateNotFound` `event.retry` promise errors.

Plunkr here: https://plnkr.co/edit/3FvvL5eANYqTnx9oxO8C

Click on Top state and look in the developer console: it prints transition failed. From what I understand it shouldn't. I need to perform some action on transition failure and hooking to the $stateChangeError will be a pain because other places will change state and I don't want to handle their failures. Also I need some closure from the function calling $state.go.

jdmichaud commented 7 years ago

Can anyone confirm this issue?

christopherthielen commented 7 years ago

If I remember correctly, the initial transition is cancelled while waiting for the future state to load, then a new transition is started

christopherthielen commented 7 years ago

note: future states are in ui-router core in 1.0.0-beta.2 now