Stack Overflow Asked on December 8, 2020
I am wondering how you can render the same instance of an angular component in multiple places? For example: I am using this angular mat-stepper component. mat-stepper
I need to make it so that I can render the same component in each the horizontal and vertical stepper but i need to have the same one. The reason for this is that in each one I have a form and I need the same instance of the form whether it is vertical or horizontal mode. If i just instantiate the same component in each horizontal/vertical mode then it maintains two instances in both horizontal/vertical. So if I update the form in one the changes dont go over to the other and vice versa. Any ideas how to solve that would be greatly appreciated. Thank you.
I think you do not need to use the same instance of components, but try to use some service to share states between components.
Service could have
Subject of your actual form values. And you should be
subscribed to changes of your subject and update form values.
Answered by Filip on December 8, 2020
Get help from others!