Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AngualrJS ui-router logger snippet (helps for debug)
// Credits: Adam's answer in
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to ''- fired when the transition begins. toState,toParams : \n',toState, toParams);
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
$rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeSuccess to ''- fired once the state transition is complete.');
console.log('$viewContentLoaded - fired after dom rendered',event);
$rootScope.$on('$stateNotFound',function(event, unfoundState, fromState, fromParams){
console.log('$stateNotFound '' - fired when a state cannot be found by its name.');
console.log(unfoundState, fromState, fromParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.