如何调试在浏览器的角度服务 [英] how to debug angular services in browser
本文介绍了如何调试在浏览器的角度服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的角度应用创造了一个工厂/服务。
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 ?
推荐答案
我相信你可以使用这样的:
I believe you can use something like this:
angular.element(e).injector().get('serviceName')
和自angularjs服务的单身,任何这样的 angular.element 的总是会返回相同的服务实例/对象。
And since angularjs services are singletons, doing this on any angular.element will always return the same service instance/object.
这篇关于如何调试在浏览器的角度服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文