Anthony Humes
When critical production issues arose, it was hard to debug them effectively costing time and resources
to build good apps, you must be able to debug them effectively
to debug effectively, you must be able to use all of your available tools
Comes directly from Ivy internal methods
// Global variable in the console
ng
{
getComponent: ƒ getComponent(element),
getContext: ƒ getContext(element),
getListeners: ƒ getListeners(element),
getOwningComponent: ƒ getOwningComponent(elementOrDir),
getHostElement: ƒ getHostElement(componentOrDirective),
getInjector: ƒ getInjector(elementOrDir),
getRootComponents: ƒ getRootComponents(elementOrDir),
getDirectives: ƒ getDirectives(element),
applyChanges: ƒ applyChanges(component)
}
$0
<p class="some-element"></p>
<div class="some-div">
<p class="some-element">
Hey there text!
</p>
</div>
most recent selection from the Elements Inspector or from using Inspect Element
retrieves the component from an HTML element
retrieves an array of directives from an HTML element
returns an array of both html (ex. click) and host listeners for an HTML element
<app-parent class="some-div">
<app-child class="some-element">
Hey there text!
</app-child>
</app-parent>
ng.getComponent($0)
ChildComponent {...}
let component = ng.getComponent($0)
component.value = 10;
ng.applyChanges($0)
<app-element class="some-div">
<p class="some-element">
5
</p>
</app-parent>
<app-element class="some-div">
<p class="some-element">
10
</p>
</app-parent>
triggers change detection for the component or directive
returns the parent component for the HTML element
returns the context of an *ngIf or *ngFor for the HTML element
The current API is a work in process. These methods are the starting point to a way more powerful set of debug tools than ng.probe. More methods and better functionality will be coming in the future.