Hi,
I created my own component and added it as content to a tab component. It somehow gets initialized twice and setting the bound property also calls the setter twice. This happens if using the ng-template approach below.
However, if I use the HTML element approach, the constructor and the setter are only called once.
May I know why this is happening? I would prefer to use the first approach (using ng-template) as it is more readable than the second one.
Jose
Hi Jose,
We have prepared sample based on the shared details to reproduce the reported issue. But, component constructor is called only once.
Could you please share the below details to reproduce the issue? This will help to validate the issue and provide prompt solution at earliest.
Regards,
Satheesh Kumar B
Hi Satheesh,
See sample below.
https://stackblitz.com/edit/angular-reuse-content-wugutd?file=app.component.html
The difference between this example and your example is the tab module used.
You used TabAllModule, while I was using TabModule.
Regards,
Jose
Hi Jose,
In shared sample, you have defined “heightAdjustMode” property value as Auto. In this case alone, we rendered the tab content twice at initial load and tab switching cases for tab content height calculations. For other heightAdjustMode values, we will render the tab content only once.
Please let us know for further assistance.
Regards,
Satheesh Kumar B
Hi Satheesh,
Removing the property fixed the issue.
Thank you for your help.
Jose
Hi Jose,
You are most welcome!!!
Please get back to us if you need any further assistance.
Regards,
Vengatesh