[Angular 2] How To Debug An Angular 2 Application - Debugging via Augury or the Console
In this lesson we will learn several ways to debug an Angular 2 application, including by using Augury and the console. This is especially useful in situations (typically in enterprise development) where we are not administrators on our machine and don't have Chrome available, our we do have it but are forbidden from installing Chrome extensions.
Select heroes component in console:

Then if you type $0 in console, it will print out current component:

This is actually get DOMElement, what we want is JS object, then we can programme somthing on it.
Todo this, we need to use one comand to get the component instance:
ng.probe($0).componentInstance // get component instance

Now we get the object, lets try to change the Hero which id = 1, change the name to "Superman".

We changed value in console, but it doesn't refect on UI. This is because Angular 2 Change detection.
We need to trigger it by:
ng.probe($0)._debugInfo._view.changeDetectorRef.detectChanges() // trigger the change detection
Once we run it, the UI will change.
But doing this is lots of work, we can use Augury. You can install it from Chrome extension.
Then you can get a more user friendly interface:

You can chang value and it will immdeticlly reflect on the interface.
-----------------------
If you want to check the class if componet use, you can do:
$0.classList
[Angular 2] How To Debug An Angular 2 Application - Debugging via Augury or the Console的更多相关文章
- [Angular 2 Router] Configure Your First Angular 2 Route
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...
- 【Angular专题】——(1)Angular,孤傲的变革者
目录 一. 漫谈Angular 二. 如果你还在使用Angularjs 三. 我计划这样学习Angular技术栈 一. 漫谈Angular Angular,来自Google的前端SPA框架,与Reac ...
- [Angular] Use Angular components in AngularJS applications with Angular Elements
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...
- Angular 从入坑到挖坑 - Angular 使用入门
一.Overview angular 入坑记录的笔记第一篇,完成开发环境的搭建,以及如何通过 angular cli 来创建第一个 angular 应用.入坑一个多星期,通过学习官方文档以及手摸手的按 ...
- [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)
前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...
- Angular项目构建指南 - 不再为angular构建而犹豫不决(转)
如果你不知道什么是Angular或者根本没听说过,那么我接下来所说的对你来说毫无益处,不过如果你打算以后会接触Angular或者干脆要涨涨姿势~读下去还是有点用的. Angular和它之前所出现的其余 ...
- This Debug perspective is designed to support application debugging.it incorporates views for displaying the debug stack,variables and breakpoint mamagement
使用IDE(Eclipse Version:Neon.2 Release (4.6.2)),出现以下提示信息: This kind of launch is configured to openthe ...
- angular源码分析:图解angular的启动流程
今天做了一些图来说明angular,由于angular实在太复杂了,不知道用什么图表示比较好,所以就胡乱画了一些,希望有人能看得懂. 一.源码文件编译合并顺序图 二.angular.module函数功 ...
- [Angular 2] Nesting Elements in Angular 2 Components with ng-content (AKA Angular 2 Transclusion)
You can place content inside of the instance of your component element then manage it inside of the ...
随机推荐
- 音频PCM格式
经常见到这样的描述: 44100HZ 16bit stereo 或者 22050HZ 8bit mono 等等. 44100HZ 16bit stereo: 每秒钟有 44100 次采样, 采样数据用 ...
- hadoop中日志聚集问题
遇到的问题: 当点击上面的logs时,会出现下面问题: 这个解决方案为: By default, Hadoop stores the logs of each container in the nod ...
- 认识Java虚拟机的内部体系结构、gc示例
认识Java虚拟机的内部体系结构 Java虚拟机的内部体系结构也许很少有人去关心,因为对于Java程序员来说,一般只需要跟API打交道就可以了.这些体系结构只是Java虚拟机内部的结构而已.但是如果理 ...
- Libsvm的MATLAB调用和交叉验证
今天听了一个师兄的讲课,才发现我一直在科研上特别差劲,主要表现在以下几个方面,(现在提出也为了督促自己在以后的学习工作道路上能够避免这些问题) 1.做事情总是有头无尾,致使知识点不能一次搞透,每次在用 ...
- Python绘图和数值工具:matplotlib 和 numpy下载与使用
安装任何python模块的标准方式是使用标准的python版本,然后添加标准的模块最简单的方法是登陆相应的网站下载程序包. 但是要考虑依赖关系 , 平台和Python版本号. windows一般带有安 ...
- Apache:如何利用.htaccess文件对PHP网站或文件进行伪静态处理
来源:http://www.ido321.com/1123.html 今天get了一招:利用.htaccess文件对PHP网站或文件进行伪静态处理. 一.检查服务器是否支持伪静态处理: 必 须要空间支 ...
- Ubuntu中使用pyUSB读取鼠标或键盘的数据程序
参考 :http://www.orangecoat.com/how-to/read-and-decode-data-from-your-mouse-using-this-pyusb-hack 要注意的 ...
- quick-x在windows平台打包加密文件
D:\quick-cocos2d-x-2.2.1-rc\bin>compile_scripts -i ..\mygames\myth\scripts -o ..\mygames\myth\res ...
- 第三百零四天 how can I 坚持
我以为我遇到了,却是痴心妄想啊.哪有那么好的事.其实也无所谓,淡定,却又有点不淡定了. 洗澡睡觉吧,明天还要上班呢. 应该摆脱这种状态. 什么都不想,放空.
- Mysql数据库插入的中文字段值显示问号的问题解决
最近我使用myeclipse连接mysql数据库查询表中的数据,表中字段值为中文的字段显示问号,查了很多资料将解决方法总结如下: 步骤一:修改mysql数据库的配置文件my.ini或者my-defau ...