【发布时间】:2021-09-04 10:47:46
【问题描述】:
组件:
import { Component, OnInit, TemplateRef } from '@angular/core';
import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
export class PatchListComponent implements OnInit {
modalRef: BsModalRef;
constructor(private modalService: BsModalService) {
openModal(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template);
}
}
}
模块:
import { ModalModule } from 'ngx-bootstrap/modal';
@NgModule({
declarations: [
MyComponent
],
imports: [
ModalModule.forRoot(),
]
})
export class MyModule { }
得到以下错误:
属性 'modalRef' 没有初始化器,也没有在构造函数中明确赋值
提前致谢。
【问题讨论】:
标签: angular ngx-bootstrap