I have a container that contains two independent components.
The list of users comes to the first component from the backend part.
When clicking on a specific user, I need to show all of his complete information in the general container of the second independent component.
I presented my code in Stackblitz
It doesn't work quite right when removing an added component. It is not the selected component that is deleted, but only the last one.
Can anyone help me where is the error?
userIdis alwaysundefinedwhen callingthis.appService.removeUser(userId);. This is because of an issue in your template, you were callingremoveUser(options.userId)instead ofremoveUser(options.id):Also, notice that
viewContrainerRef.removetakes theindexof an element, not an id. So you need to be carefull to pass the right index. (0 for the fist element, 1 for the 2nd etc).