I'm doing an web application that is supposed to work like the contacts app that we have in our phones:
So I have a list.component (a grey mat-card) and a contact.component , (an orange mat-card).
I want to spawn a new contact.component inside of the list.component , and destroy it when the user select the delete button.
The data is passing fine, but I don't know how to add a new existing component inside another.
You could save the contacts inside a public array and then iterate over it inside the list-component:
<list-component>
<ng-container *ngFor="let contact of contactArray">
<contact-component></contact-component>
</ng-container>
</list-component>
When the user adds another contact, you can push it to the contactArray and the additional contact-component will appear
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.