Read our angular tutorial and join our #DailyAngularChallenge where we learn to build The type of the divView variable is our ElementRef interface which means we can access the nativeElement object that reprents the DOM element in the browser. This page was last modified on 26 nov 2022 by MDN contributors. Example: If you add a
with the myDiv reference in our component template. AfterViewInit is a life-cycle method of components that gets called when the view of the component is completely rendered. In case it is a browser environment like the one we will see in these tests, there will be an HTMLElement and the object will be the same that we will find in debugElement.nativeElement. It holds the reference to the DOM element and uses it to manipulate the DOM. In this first example, the first