Twitter bootstrap 如何使用ViewChild在ngAfterViewInit方法上打开模态?

Twitter bootstrap 如何使用ViewChild在ngAfterViewInit方法上打开模态?,twitter-bootstrap,angular6,Twitter Bootstrap,Angular6,我正在用angular 6编写模式模板,我一直在学习引导弹出窗口的教程,但当我试图用ngAfterViewInit方法打开模式时,它不起作用,也永远不会打开 我正在处理angular 6,并试图在ts文件中以ViewChild的形式打开一个模式,但我不知道为什么它不起作用,目标是运行模式稍后页面已启动,以向人们提供建议。谁能帮帮我吗 档案更新 &时代; 出生日期 拯救 完成 我刚刚更改了ts文件 从'@angular/core'导入{Component,OnInit,AfterViewIn

我正在用angular 6编写模式模板,我一直在学习引导弹出窗口的教程,但当我试图用ngAfterViewInit方法打开模式时,它不起作用,也永远不会打开

我正在处理angular 6,并试图在ts文件中以ViewChild的形式打开一个模式,但我不知道为什么它不起作用,目标是运行模式稍后页面已启动,以向人们提供建议。谁能帮帮我吗


档案更新
&时代;
出生日期
拯救
完成

我刚刚更改了ts文件

从'@angular/core'导入{Component,OnInit,AfterViewInit,ViewChild,ElementRef};
从'@ng bootstrap/ng bootstrap'导入{NgbModal,modaldismissreases};
将*作为jQuery从“jQuery”导入;
@组成部分({
选择器:“应用程序广告模式”,
templateUrl:“./advision modal.component.html”,
样式URL:['./广告模式.component.css']
})
导出类AdvertisementModalComponent实现OnInit,AfterViewInit{
closeResult:字符串;
@ViewChild(“内容”)myModal:任何;
构造函数(私有modalService:NgbModal){}
打开(内容){
this.modalService.open(内容,{arialabledby:'modal basic title'}).result.then((result)=>{
this.closeResult=`Closed with:${result}`;
},(原因)=>{
this.closeResult=`disposed${this.getDismissReason(reason)}`;
});
}
私有getDismissReason(原因:任意):字符串{
if(reason==modaldismissreasions.ESC){
返回“按ESC键”;
}else if(reason==ModalDismissReasons.background\u单击){
返回“点击背景”;
}否则{
返回`with:${reason}`;
}
}
ngAfterViewInit(){
this.open(this.myModal);
}
恩戈尼尼特(){
}
}