I am currently facing an issue where I am attempting to invoke a modal function within the constructor in Angular 4. However, it seems that the function is not being called properly as it gets highlighted. Upon loading the page, no errors are logged and the modal does not appear as expected. While the screen darkens, the text inside the modal does not display.
constructor(public formBuilder: FormBuilder,
public router: Router,
public toastr: ToastrService,
public http: HttpClient,
public modalService: BsModalService,) {
if (this.getWardData) {
this.displayHint();
}
}
displayHint(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template, {class: 'modal-sm'});
}
HTML
<ng-template #template>
<div class="modal-body text-center">
<p>Do you want to Continue where you left?</p>
<button type="button" class="btn btn-default" (click)="confirm()" >Yes</button>
<button type="button" class="btn btn-primary" (click)="decline()" >No</button>
</div>
</ng-template>