1
这是我的服务,返回Typescript Error Property 'comments' does not exist on type '{}'
。当应用程序用来初始化,而不是第一评论评论类型'{}'上不存在Typescript错误属性'comments'
getMessages() {
let observable = new Observable(observer => {
this.socket = io(this.url);
this.socket.on('add comment', (data) => {
observer.next(data);
});
return() => {
this.socket.disconnect();
};
})
return observable;
}
后,这是我的功能
ngOnInit() {
this.connection = this.chatService.getMessages().subscribe((comment) => {
console.log("comment",comment);
comment.comments[0].createdBy.profilePicture = comment.comments[0].createdBy.profilePicture;
this.issue.comments.push(comment.comments[0]);
})
}
这是我的服务返回Typescript Error Property 'comments' does not exist on type '{}'
。当应用程序初始化时,而不是在第一条评论之后被评论
谢谢PierreDuc。你拯救了我的一天 –