What is ElementRef in angular 4?
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
BY Best Interview Question ON 19 Dec 2019