In this lesson we'll learn several ways to debug a Angular 2 application, including by using Augury and the console. This was especially useful in situations (typically in enterprise development) where we were not administrators on our Machi NE and don ' t has chrome available, our we do has it but is forbidden from installing Chrome extensions.
Select Heroes component in console:
Then if you type $ in console, it'll print out the current component:
This was actually get domelement, what we want are JS object, then we can programme somthing on it.
Todo this, we need to use one comand to get the component instance:
Ng.probe ($). 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 was because Angular 2 change detection.
We need to trigger it by:
// trigger The change detection
Once We run it, the UI would change.
But doing the 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'll 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