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

Suggest An Answer

No suggestions Available!