Angular 发生客户端或网络错误:无法读取未定义的属性(读取“viewContainerRef”)
我使用以下 forkJoin
仅对可预览的附件进行预览调用。 canPreview
标志表明了这一点。
但是一旦我添加过滤器,它就会抛出以下错误。我没有在此组件中的任何地方使用 viewContaienrRef
。谁能帮助找出我在这里做错了什么?
'A client-side or network error occurred: Cannot read properties of undefined (reading 'viewContainerRef')'
forkJoin(
this.question.attachments
.filter(attachment => attachment.canPreview) //error after adding this line
.map((attachment) => {
const { fileName, attachmentId, canPreview } = attachment;
const attachmentUploadResult: AttachmentUploadResult = {
fileName,
attachmentId,
canPreview
};
return this.uploadService.getBlob(attachmentId).pipe(
map((blob) => {
return {
fileName,
attachmentId,
imageURL: this.sanitizer.bypassSecurityTrustUrl(
URL.createObjectURL(blob)
),
canPreview
} as AttachmentUploadResult;
}),
catchError(() =>
of(attachmentUploadResult)
)
);
})
)
谢谢
I am using the following forkJoin
to make preview call only for attachment that can be previewable. canPreview
flag shows that.
But as soon as I add the filter, it is throwing the following error. I am not using viewContaienrRef
anywhere in this component. Can anyone help to find what am I doing wrong here?
'A client-side or network error occurred: Cannot read properties of undefined (reading 'viewContainerRef')'
forkJoin(
this.question.attachments
.filter(attachment => attachment.canPreview) //error after adding this line
.map((attachment) => {
const { fileName, attachmentId, canPreview } = attachment;
const attachmentUploadResult: AttachmentUploadResult = {
fileName,
attachmentId,
canPreview
};
return this.uploadService.getBlob(attachmentId).pipe(
map((blob) => {
return {
fileName,
attachmentId,
imageURL: this.sanitizer.bypassSecurityTrustUrl(
URL.createObjectURL(blob)
),
canPreview
} as AttachmentUploadResult;
}),
catchError(() =>
of(attachmentUploadResult)
)
);
})
)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论