Modal in separate Component

Asked

Viewed 266 times

0

Hello, I’m new in Bootstrap with angular, and would like to know if there is a way to create a modal in one Component and call it in another, for example:

Component-parent Component-modal

then the parent Component would have a button that would call the Component-modal.

Thank you in advance...

1 answer

1


Create modal in Component-modal.html

Use *ngIf in Component-parent.html

<button (click)="adicioneComponentModal()">Adicione Component Modal</button>
<component-modal *ngIf="modals != null"></component-modal>

In the Component-father.ts

modals: ComponentModal = null;

adicioneComponentModal() {
    this.modals = new ComponentModal();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.