I’ve created something like a tabs component where i’m loading some content based on the value of the selected tab. However each time I go between the tabs it loads the data from my service again on top of the old data so I get duplicates…
This is in my component:
ngOnInit() {
if (Meteor.userId()) {
if (this.myTasksSub) {
this.myTasksSub.unsubscribe();
}
this.myTasksSub = MeteorObservable.subscribe('entities').subscribe(() => {
MeteorObservable.autorun().subscribe(() => {
this.myTasks = this._entityService.findMyTasks(this.user);
});
});
}
}
and I load it in the standard way in my html:
<ul *ngIf="selectedTab==1">
<li *ngFor="let myTask of myTasks | async">
what am i doing wrong?