Modal in separate components

0
Hello, I'm new to Bootstrap with angular, and I would like to know if a way to create a modal in one component and call it in another, for example:

Component-parent component-modal

so the parent component would have a button that would call the component-modal.

Thank you in advance ...

    
asked by anonymous 06.08.2018 / 00:15

1 answer

1

Create the 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>

No Component-parent.ts

modals: ComponentModal = null;

adicioneComponentModal() {
    this.modals = new ComponentModal();
}
    
06.08.2018 / 00:46