【发布时间】:2021-08-25 07:58:15
【问题描述】:
我在 Angular 8 项目中 npm install @ng-bootstrap/ng-bootstrap@5.3.1,当我使用模态服务打开模态时,第一次尝试打开模态需要时间。第二次模态不打开。查看开发工具,模式是打开的,只是没有设置 CSS 类。我确实将 bootstrap 导入到 styles.scss 文件 @import "~bootstrap/scss/bootstrap.scss"; 我尝试在打开模型后使用 JavaScript 注入 CSS 类,但没有任何区别。
@ViewChild('modalContent', { static: false }) private modalContent: TemplateRef<any>;
// .....some code here....
public openNgbModal(): NgbModalRef {
return this.modalService.open(this.modalContent, {
size: 'lg',
backdrop: 'static',
keyboard: false,
windowClass : 'modal-content'
});
}
见下文:
【问题讨论】:
-
您是否在
angular.json中导入引导脚本? -
是的,我确实导入了脚本
-
如果文件已加载,您能否在 F12 中看到
-
为什么还要使用
return?也许试试.show -
我正在使用版本 5 的 ng-bootstrap(角度 8)没有
.show。我使用 return 是因为我正在调用该函数来打开模型,而不是每次都调用this.modalService.open
标签: javascript css angular ng-bootstrap