0

In parent.component.html

I have the following HTML

<button type="button" class="btn btn-secondary (click)="AddComponentAdd()">Address</button> 
<app-addresse *ngFor="let addres of collOfAdd" [add]="addres"></app-addresse>

and in parent.component.ts

private collOfAdd: Array<AddresseComponent> = [];

AddComponentAdd() {
    this.collOfAdd.push(AddresseComponent); 
}

and in addresse.component.ts

 @Input() add: string;

How do I make the component <app-addresse> appear several times in the parent component by clicking the button present in parent component?

2 Answers 2

1

I also created a stackblitz link. https://stackblitz.com/edit/angular-lnyec5

Sign up to request clarification or add additional context in comments.

2 Comments

@Fat16 I didn't get how the above stackblitz code worked for you? there is no button in the answer provided?
I made changes to your solution !
0

I have created a stackblitz for your question please check the below url: https://stackblitz.com/edit/angular-tihubf

In this reference you can find hello.component loaded multiple times on click of button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.