【发布时间】:2021-12-01 20:22:24
【问题描述】:
对于这行特定的代码,我收到一个错误:对象为空或未定义。
private modalService: BsModalService
const modalRef = this.modalService.show(ABStationDialogComponent);
modalRef.content.presetStations = this.allStations;
modalRef.content.editStation = JSON.parse(JSON.stringify(this.editStation)); // Deep copy
modalRef.content.relatedFrom = this.editAbEntry.fromDate ? this.editAbEntry.fromDate : '';
modalRef.content.relatedTo = this.editAbEntry.toDate ? this.editAbEntry.toDate : '';
modalRef.content.editStations = this.editStations;
modalRef.content.pageReady = true;
我尝试使用可选链接但没有帮助。然后我收到此错误:
The left-hand side of an assignment expression may not be an optional property access.
请查看图片和错误。
即使尝试用 if 语句结束也无济于事。安装 webpack 5 后,我的 Angular 应用程序中出现此错误。
有人可以帮我解决这个问题吗?
【问题讨论】:
-
this.modalService.show(ABStationDialogComponent);返回什么? -
它是一个引导模式服务@depperm github.com/valor-software/ngx-bootstrap/blob/development/src/…