【发布时间】:2020-02-12 10:50:58
【问题描述】:
当打开引导模式对话框时,模式窗口会立即关闭 - 只有在调试时才能看到。查看我的代码: 开瓶器的html:
<span>
<span>
<button type="button" (click)="openDialog()">
Open dialog
</button>
</span>
</span>
组件代码:
export class dialogOpener implements OnInit {
constructor(private modalService: NgbModal) { }
openDialog()
{
const modalRef : NgbModalRef = this.modalService.open(modalDialogComponent);
}
}
模态窗口Html:
<p>modalDialog works!</p>
组件代码:
export class modalDialogComponent {
constructor(private activeModal: NgbActiveModal, private modalService: NgbModal) { }
}
app.module.ts:
@NgModule({
declarations: [
...
AppComponent,
modalDialogComponent,
],
imports: [
...
],
entryComponents:[modalDialogComponent],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
这里有什么问题?
【问题讨论】:
-
免责声明:我真的不知道。但是您是否尝试过在您的
modalDialogComponent中将NgbActiveModal设为公共课程? -
@Francisco Santorelli - 是的,没有帮助
标签: angular bootstrap-4 bootstrap-modal