I have an event emitter and 5 subscriber's in each of the 5 pages say(Page 1, Page 2, Page 3, Page 4, Page 5)
I subscribed for the event on the ngOnInit() and unsubscribe it on ngOnDestroy(),
These pages are actually routed pages , ie only only one page will be loaded to the DOM at once
So my use case is Initially i go to Page 1 and triggered the event emitter Then i move to Page 2 again triggered the event emitter I can observe that this event emitter triggered the subscription in both Page 1 and Page 2,
How it is possible because i have already unsubscribed, How can i fix this ?
ngOnInit() {
this.translationService = this.sharedService.language_english.subscribe(
data => {
console.log(data)
this.trigger_translation_module(data);
}
);
}
ngOnDestroy() {
this.translationService.unsubscribe();
}