I am facing an issue with ComponentB, which contains HTML code for a Bootstrap modal. I want to open ComponentB from ComponentA.
Although the component is getting loaded when inspected, the popup modal does not appear on the UI.
<app-root>
<app-a>
<app-b></app-b>
</app-a>
</app-root>
NOTE: There is no CSS applied to either of the components.
ComponentA.html:
<button (click)="popup()">Open</button>
<app-b *ngIf="openModal" [openModal]="true" ></app-b>
ComponentA.ts:
popup(){
this.openModal = true;
}
componentB.html:
<div *ngIf="openModal" id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
componetb.ts:
@Input('openModal') openModal : boolean
Thank you for your help!