title: Angular4 calling a function in constructor
body: <p>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.</p>
  
  <pre><code>constructor(public formBuilder: FormBuilder,
              public router: Router,
              public toastr: ToastrService,
              public http: HttpClient,
              public modalService: BsModalService,) {
    if (this.getWardData) {
      this.displayHint();
    }
  }
  
  displayHint(template: TemplateRef&lt;any&gt;) {
    this.modalRef = this.modalService.show(template, {class: 'modal-sm'});
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;ng-template #template&gt;
    &lt;div class="modal-body text-center"&gt;
      &lt;p&gt;Do you want to Continue where you left?&lt;/p&gt;
      &lt;button type="button" class="btn btn-default" (click)="confirm()" &gt;Yes&lt;/button&gt;
      &lt;button type="button" class="btn btn-primary" (click)="decline()" &gt;No&lt;/button&gt;
    &lt;/div&gt;
  &lt;/ng-template&gt;
  </code></pre>