[英]Debug angular app from outside (browser console only)
I have this angular website which for some reason cannot be debugged when everything is concat together (not minified). 我有这个有角度的网站,当所有内容连接在一起(未压缩)时,由于某种原因无法调试。 Fo example, if I try to set a breakpoint, the breakpoint is placed somewhere else (at the bottom of an other file) :(
例如,如果我尝试设置一个断点,则该断点将放置在其他位置(在另一个文件的底部):(
So, to overcome this I would like to set a breakpoint using the browser console (if possible of course). 因此,为了克服这个问题,我想使用浏览器控制台设置一个断点(如果可能的话)。
In my current situation I need to set a breakpoint inside a service method. 在当前情况下,我需要在服务方法内设置一个断点。 So I figured, I need the reference holding that service.
所以我想,我需要拥有该服务的参考资料。 But where does angular keep those.
但是棱角将那些保留在哪里。 For example, I tried this
例如,我尝试了这个
$> var myApp = angular.module('myApp');
$> debug(myApp.injector('someSevice').someMethod);
If this would work, I would expect the debugger to kick in when someMethod
is called. 如果这行得通,我希望调试器在调用
someMethod
时启动。
Here is an other failed attempt: 这是另一个失败的尝试:
$> myApp.run((someService) => { debug(someService.someMethod)});
Any help on how to do this would be appreciated? 任何帮助如何做到这一点将不胜感激?
UPDATE: Find a way to access a service 更新:找到一种访问服务的方法
$> angular.injector(['myApp']).get('someService').someMethod
However, in my case, this function is called initially only 但是,就我而言,此函数仅在最初被调用
If you're trying to debug a live production app, there might be a chance where the debug info
is disabled for the website which is actually done to increase performance
of the website. 如果您要调试实时生产应用程序,则可能会禁用该网站的
debug info
,而这样做实际上是为了increase performance
网站的increase performance
。 So use angular.reloadWithDebugInfo();
因此,使用
angular.reloadWithDebugInfo();
in console and then try to debug. 在控制台中,然后尝试调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.