component constructor called twice if inside ng-template

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


5 Replies 1 reply marked as answer

SK Satheesh Kumar Balasubramanian Syncfusion Team April 22, 2022 11:41 AM UTC

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. 

  • Replicate the issue in above sample (or) share simple issue replicating sample if possible
  • Share portofolio-snapshot component related code snippets with syncfusion package version of your application

 

Regards,

Satheesh Kumar B



JO Jose April 22, 2022 12:20 PM UTC

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



SK Satheesh Kumar Balasubramanian Syncfusion Team April 26, 2022 12:37 PM UTC

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


Marked as answer

JO Jose April 28, 2022 06:05 AM UTC

Hi Satheesh,


Removing the property fixed the issue.

Thank you for your help.


Jose



VM Vengatesh Maniraj Syncfusion Team April 29, 2022 03:51 AM UTC

Hi Jose,


You are most welcome!!!

Please get back to us if you need any further assistance.


Regards,

Vengatesh


Loader.
Up arrow icon