Get a service instance through the console

In Angular 1, you can get the injector through the console, which allowed you to get any service:

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

It was very useful for debugging. What is equivalent in NG2?

+7
angular
source share
1 answer

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

See also how to access Angular2 specific components in the console?

But this is not available when enableProdMode() called enableProdMode() debuggin only)

+4
source share

All Articles