I have successfully implemented a bootstrap modal window that opens on a button click. However, I am now facing difficulty in opening the same modal window from a different component. Below is the code I have tried:
<section>
<button type="button" class="btn btn-primary" (click)="openModal()">Sign In</button>
<div id="signInModal" class="modal fade m-5" role="dialog"
aria-labelledby="dialog-sizes-name2" data-backdrop="static">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<h6 class="circularBold signUpHeading">Sign In</h6>
<button type="button" class="close" aria-label="Close" data-dismiss="modal">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form [formGroup]="signInForm">
<div class="mt-4">
<button type="button" class="btn buttons nextBtn circularBold w-100" (click)="login()">Log in</button>
<p class="black2E circularBook mt-4 font-size12">Don't have an account?
<a href="" class="circularMedium">Sign up</a>
</p>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
TS
openModal() {
$('#signInModal').modal('show');
}
Code from another component
modalRef: BsModalRef;
constructor(
private modalService: BsModalService
) { }
join(){
this.modalRef = this.modalService.show(SigninComponent);
}
Any assistance on this issue would be highly appreciated.
Thank you in advance!