DOM can't find element with id on ngOnInit if element is child of p-tabview

UI Components for Angular
Post Reply
driga
Posts: 21
Joined: 03 Oct 2016, 20:58

07 Jun 2017, 09:57

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

AkashMishra
Posts: 1
Joined: 11 Jan 2022, 10:04

12 Jan 2022, 05:56

Same issue with me

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests