Skip to content

Instantly share code, notes, and snippets.

@ceoaliongroo
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceoaliongroo/3118de47af12b9fb47a0 to your computer and use it in GitHub Desktop.
Save ceoaliongroo/3118de47af12b9fb47a0 to your computer and use it in GitHub Desktop.
Angular (ng) services debug via console.
var ng = ngDebug;
var $filter;
function getService(name) {
return angular.element('body').injector().get(name);
};
function ngDebug(name) {
var providers = [];
angular.module(name)._invokeQueue.forEach(function(item){
(item[0]==='$provide') && providers.push(item[2][0]);
});
providers.forEach(function(provider) {
// Load Service.
ng[provider] = getService(provider);
})
// Load angular usefull services.
$filter = getService('$filter');
};
ngDebug(angular.element('[ng-app]').attr('ng-app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment