Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Service instance via console

Tags:

angular

In Angular 1, you could get the injector via the console, which allowed you to then get any service:

angular.element(document.querySelector('html')).injector().get('MyService')

This was extremely useful for debugging. What's the equivalent in NG2?

like image 571
David Avatar asked Oct 06 '16 06:10

David


1 Answers

You can use ng.probe($0) in the console to get debug information about your Angular2 application.

See also how to access Angular2 component specific data in console?

But that is not available when enableProdMode() was called (only for debuggin)

like image 158
Günter Zöchbauer Avatar answered Oct 10 '22 22:10

Günter Zöchbauer