DebugElement

export class DebugElement

exported from angular2/core defined in angular2/src/core/debug/debug_element.ts (line 7)

A DebugElement contains information from the Angular compiler about an element and provides access to the corresponding ElementInjector and underlying DOM Element, as well as a way to query for children.

A DebugElement can be obtained from a ComponentFixture or from an ElementRef via inspectElement.

Members

componentInstance : any

Return the instance of the component associated with this element, if any.

nativeElement : any

Return the native HTML element for this DebugElement.

elementRef : ElementRef

Return an Angular ElementRef for this element.

getDirectiveInstance(directiveIndex: number) : any

Get the directive active for this element with the given index, if any.

children : DebugElement[]

Get child DebugElements from within the Light DOM.

componentViewChildren : DebugElement[]

Get the root DebugElement children of a component. Returns an empty list if the current DebugElement is not a component root.

triggerEventHandler(eventName: string, eventObj: Event) : void

Simulate an event from this element as if the user had caused this event to fire from the page.

hasDirective(type: Type) : boolean

Check whether the element has a directive with the given type.

inject(type: Type) : any

Inject the given type from the element injector.

getLocal(name: string) : any

Read a local variable from the element (e.g. one defined with #variable).

query(predicate: Predicate<DebugElement>, scope?: Function) : DebugElement

Return the first descendant TestElement matching the given predicate and scope.

queryAll(predicate: Predicate<DebugElement>, scope?: Function) : DebugElement[]

Return descendant TestElememts matching the given predicate and scope.