|
<ejs-tab id="element" #element (selected)="select($event)" (created)=created($event) >
<e-tabitems>
<e-tabitem [header]='headerText[0]' content="#idv"></e-tabitem>
<e-tabitem [header]='headerText[1]' content="#idv" ></e-tabitem>
</e-tabitems>
</ejs-tab>
<div id="idv" >
<router-outlet></router-outlet>
</div>
Ts:
public created(e){
this.tabObj.items.push({ header: { text: 'MyForm' }, content: "#idv" }); // refer the router id
(<any>this.tabObj).refresh();
}
public select(e: any) { //based on the selection index the page will load with the dynamic components in it
if (e.selectedIndex == 0) {// selected index
this.router.navigateByUrl('/home');
}
else if (e.selectedIndex == 1) {
this.router.navigateByUrl('/about');
}
else if (e.selectedIndex == 2) {
this.router.navigateByUrl('/home');
}
}
|
Hi Turboshurik,
Thanks for your patience.
We further validated your reported issue and found that the
reported issue is related to sample end. Using the code snippet below we can
add the dynamic custom component in tab without using router. We suggest that
you follow the sample below and refer to the shared UG.
App.component.html
|
<hello style="display: none" id='custom'> </hello> |
App.component.ts
|
addDynamicTabComponent() { const count: number = this.tabObj.items.length; const item1: Object = { header: { text: 'Tab ' + count }, content: '#custom' }; this.tabObj.addTab([item1], this.tabObj.items.length); this.tabObj.dataBind(); this.tabObj.select(count); } |
Sample: https://stackblitz.com/edit/angular-dynamic-tab-creation-with-component-content-molqa3
UG links:
https://ej2.syncfusion.com/angular/documentation/tab/how-to/load-tab-items-dynamically/
https://ej2.syncfusion.com/angular/documentation/tab/how-to/adding-dynamic-items-with-content-reuse/
Kindly try the above links and let us know if you need
further assistance.
Regards,
Vengatesh
HI Vengatesh Maniraj,
The problem is not resolved!
Steps to repeat:
3. Close the selected "Tab 2".
Tab 1 is displayed incorrectly! "Hello !" content is missing. It displays "#custom". This is the id of the component tag.
Hi
I've came here with same issue, can you please give an reference or sample for passing data to the binded template.