我在组件(Angular2)的ngOnInit()中订阅,然后在ngOnDestroy()中取消订阅。我的组件的第二初始化后,它给我一个错误:为什么我不能在取消订阅后在同一个EventEmitter上订阅
ObjectUnsubscribedError: object unsubscribed
在我的课,我有:
ngOnInit() {
this.chatService.getConversationsEvent()
.subscribe((data:Data<Array<Conversation>>) => {
console.log('from correspondence');
});
this.scrollToBottom();
}
ngOnDestroy() {
this.chatService.getConversationsEvent().unsubscribe();
}
这里添加一些代码 – Sreemat
添加的代码有点 –