I'm trying to call a modal function in the constructor in Angular 4 but the function get highlighted that is not properly called and when the page is loaded not error is read in the log and the modal is not popping up as its suppose to. The screen gets dark alright but the text in the modal doesn't show up.
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>