1.

What is ElementRef in angular 4?

Answer»

ElementRef is BASICALLY a class or reference types used for abstraction. The class structure holds the native elements and ElementRef is used to access the native elements

@COMPONENT({
selector: 'sample',
...EXPORT class SampleComponent{
constructor(private hostElement: ElementRef) {
   //outputs
   console.log(this.hostElement.nativeElement.outerHTML);
}

ElementRef is used to break the ABREACTION rather than using SPECIFIC API DOM like textContent



Discussion

No Comment Found