简体   繁体   English

从外部调试角度应用程序(仅浏览器控制台)

[英]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.

相关问题 有没有办法从外部(例如从浏览器控制台或附加组件)收听诸如 routechangestart 之类的角度事件? - Is there a way to listen to angular events like routechangestart from outside, like from browser console or an add on? 从 Angular 中的浏览器控制台调用 function - Call function from browser console in Angular 从浏览器控制台调用Angular click事件 - Invoking an Angular click event from browser console 无法从浏览器调试Node js应用 - Not able to debug node js app from browser jQuery 拖放 - 只允许从浏览器外部拖动 - jQuery Drag & Drop - only allow drags from outside the browser 如何从浏览器控制台禁用angular.reloadWithDebugInfo()? - How to disable angular.reloadWithDebugInfo() from browser console? 如何从 Angular 的浏览器控制台中选择选项值? - How to select option value from the browser console in Angular? 仅在浏览器控制台上,不在页面上执行jQuery代码文档就绪的操作 - jQuery code document ready is not executed on the page, only from the browser console Javascript:将Console.debug()输出写入浏览器? - Javascript: Write Console.debug() output to browser? 如何使用浏览器控制台调试 JavaScript 模块? - How to debug JavaScript modules using the browser console?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM