首页 > 解决方案 > 打开带有 angular 6 viewchild 的 bootstrap 3.3.7 模态

问题描述

我的 component.html 中有如下引导模式,如下所示

<div #myModall  class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      ...
    </div>
  </div>
</div>

我正在访问它 component.ts 如下。

 export class Component implements OnInit, AfterViewInit {
      @ViewChild('myModall') myModall: ElementRef;
  ngAfterViewInit() {

    this.myModall.nativeElement.modal('show');

  }
}

我已根据此链接 https://getbootstrap.com/docs/3.3/javascript/#modals中的 bootstrap 3.3.7 文档访问它 现在我收到如下错误。this.myModall.nativeElement.modal 不是函数。关于如何从打字稿文件访问模态并以正确的方式进行的任何建议??????

标签: javascriptangulartypescripttwitter-bootstrap-3angular6

解决方案


推荐阅读