If we create a template for a component like this
<div id="somediv1">
<p-tabView>
<p-tabPanel header="Info">
<div id="somediv2">....</div>
</p-tabPanel>
</p-tabview>
</div>
en in the component we implement OnInit
private _div1 : HTMLElement
private _div2 : HTMLElement
ngOnInit() {
this._div1 = document.getElementById('somediv1');
this._div2 = document.getElementById('somediv2');
}
_div2 is always null where _div1 is found, if we do the same thing in OnChange of the component, _div1 is found.
How can we access a DOM element by id inside the p-tabview on ngOnInit?
The reason is because we want to add a loader on top of the _div2 while fetching data for a form inside the div.
Thanks
DOM can't find element with id on ngOnInit if element is child of p-tabview
-
- Information
-
Who is online
Users browsing this forum: No registered users and 27 guests