Angular 2:如何从浏览器控制台启用angular2调试 [英] Angular 2: How enable debugging in angular2 from browser console

查看:259
本文介绍了Angular 2:如何从浏览器控制台启用angular2调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularJS 中,我们有一个名为 Angular 2 中寻找它的等效项,它可以让我们在开发人员控制台中启用调试功能.但是似乎没有与此等效的功能可以在浏览器控制台中访问.我知道有enableDebugToolsdisableDebugTools之类的功能可以使我们启用和禁用调试,但是无法在浏览器控制台中访问它们.还可以访问angular2的调试武器,例如ng& ng.probe,必须首先启用解决方案

在Angular2中进行开发时,默认情况下会启用调试信息.

需要使用启用调试工具enableDebugTools

用于生产 enableProdMode() 应该调用它来消除调试信息,从而降低您的应用程序速度并增加代码大小.

有关如何从控制台访问调试信息的详细信息,请参见 https://augury.angular.io/提供了具有图形用户界面的浏览器插件

由于是为部署而构建的Angular应用程序,因此在构建应用程序时需要启用这些选项,否则它将不会包含在可部署项中.

In AngularJS, we have a function called reloadWithDebugInfo()

angular.reloadWithDebugInfo()

which reload the current application with debug information turned on. One can execute this function in browser console and enable the debugging. I am looking for it's equivalent in Angular 2 which can let us enable debugging in developer console. But it seems like there's no equivalent function of this which can be accessed in the browser console. I know there are functions like enableDebugTools and disableDebugTools which let us enable and disable the debugging but one can not access them in browser console. And also to get access to angular2's debugging weapons like ng & ng.probe, one has to enable debug tools first as written in the Angular 2 Application Debugging Guide:

Make sure your application has production mode disabled so that you can have access to the all the methods described below.

I just want to know Is there any way to enable debug tool using console in Angular 2?

解决方案

Debugging info is enabled by default during development in Angular2.

Debugging tools need to be enabled with enableDebugTools

For production enableProdMode() should be called to get rid of debug information that slows down your application and increases code size.

For details how to access debug info from the console see how to access Angular2 component specific data in console?

https://augury.angular.io/ provides a browser Plugin with a graphical UI

Because an Angular application is built for deployment, the options need to be enabled when the application is built, otherwise it won't be included in the deployable.

这篇关于Angular 2:如何从浏览器控制台启用angular2调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆