Last active
August 29, 2015 14:21
-
-
Save ceoaliongroo/3118de47af12b9fb47a0 to your computer and use it in GitHub Desktop.
Angular (ng) services debug via console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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