Skip to content

Instantly share code, notes, and snippets.

@johnnyasantoss
Created February 9, 2017 11:50
Show Gist options
  • Save johnnyasantoss/8b5e0760abfff5542f98fb95f4361927 to your computer and use it in GitHub Desktop.
Save johnnyasantoss/8b5e0760abfff5542f98fb95f4361927 to your computer and use it in GitHub Desktop.
Use this script to debug ui-view (works with minified files too!) Just paste it on console and hit enter.
jQuery(function ($) {
var view = $("[ui-view]").first();
if (!view) return;
var $rootScope = angular.element(view).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
console.log('$stateChangeStart to ' + toState.name + '- fired when the transition begins. toState,toParams : \n', toState, toParams);
});
$rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, error) {
console.log('$stateChangeError - fired when an error occurs during transition.');
console.log(arguments);
});
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
console.log('$stateChangeSuccess to ' + toState.name + '- fired once the state transition is complete.');
});
$rootScope.$on('$viewContentLoaded', function (event) {
console.log('$viewContentLoaded - fired after dom rendered', event);
});
$rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
console.log('$stateNotFound ' + unfoundState.name + ' - fired when a state cannot be found by its name.');
console.log(unfoundState, fromState, fromParams);
});
});
@johnnyasantoss
Copy link
Author

Originally seen here, with some improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment