The best I've found is http://www.ng-newsletter.com/posts/angular-ui-router.html. It doesn't go as deep as, for example, the order in which $stateChangeStart
, exampleState.onEnter
, exampleState.resolve
, and exampleState.templateProvider
fire.
A great answer format would be clean. Something like:
Initial pageload of state foo:
- Angular lifecycle step 1
- UI router lifecycle step 1
- UI router lifecycle resolves occur
- UI router lifecycle onEnter fires
- Angular lifecycle step 2
State change foo -> bar
$stateChangeStart
event fires- foo
onExit
fires - bar
onEnter
Fires templateUrl
gets the template- UI router plugs back into the Angular lifecycle in the digest loop (or wherever).
Nested states
Multiple named views:
ui-sref clicked
Etc... Thanks!
EDIT: Debugging functions provided enough insight to meet the need. See my answer below for a snippet.
After some experimenting, I figured out how to see into the lifecycle well enough to debug my app and get a feel for what was happening. Using all the events, including onEnter, onExit, stateChangeSuccess, viewContentLoaded from here, gave me a decent picture of when things are happening in a way that's more both more flexible and specific to my code than a written out lifecycle. In the app module's "run" function, I placed:
This code would have saved me days of time and confusion if I started using it when I first started with Angular and UI-router. UI-router needs a "debug" mode that enables this by default.
How ui-router manages urls beside the default $location provider is not clear so, adding more debugging code here. Hopefully it'll be helpful. These are from https://github.com/ryangasparini-wf/angular-website-routes
I took @Adam's solution and wrap it into a service so I can switch debugging (printing to console) on and off from within my application.
In the template:
In the controller:
Or to just switch it on:
The service:
UI Router has been updated with Transition Hooks.
Use $transition$ service to access onError hook and catch the error.
List of hook :
You can checkout the overview to learn about Transition : https://ui-router.github.io/guide/transitions
See the documentation for the Transition Hook events : https://ui-router.github.io/guide/transitionhooks
I needed to debug the ui-router I was using along with the ui-router-extras sticky state package. I found that sticky states has builtin debugging that helped solve my problem. It logs information about the state transitions and which are inactive/active.
https://christopherthielen.github.io/ui-router-extras/#/sticky