Last Updated: February 25, 2016
·
2.416K
· jgrund

AngularJS: Accessing provider instances via the console

Ever want to get an instance of a service for debugging purposes in the console?

To do so you can access the injector that is available on a jQuery wrapped element and then get an instance of the service you want to look at.

For example to get an instance of the $q service you can do:

q = $('body').injector().get('$q);

You can than access any of the methods available on the $q service.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

AngularJS pages are long-lived browser apps with the same script risk as a newer single-page app. Third-party code in the template can read forms and values rendered on the page.

Security insights from Cside