I have created a factory/service in my angular app.
I want to debug it in the browser. Is there a way that I can access its instance and check what is the value of its functions and variables.
The angular scope can be accessed using
angular.element(e).scope()
Is there a similar way to access factories ?
The Console With the Chrome DevTools console, you can execute custom code and display your application logs. By running custom JavaScript code, you can debug your Angular app. For example, using console.
I believe you can use something like this:
angular.element(e).injector().get('serviceName')
And since angularjs services are singletons, doing this on any angular.element will always return the same service instance/object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With