I din't get proper answer on the internet. I may be asking wrong question. Here is my code:
filtersTree: any[];
if (...) {
this.myService.myMethodOne().subscribe(data => {
this.filtersTree = data;
});
}
else {
this.myService.myMethodTwo().subscribe(data => {
this.filtersTree = data.filters;
});
}
See data inside subscribe. Every time this code is called the previous values stays there and the whole UI is flooded with stale values along with new values.
I want to clear it before the next call is made. Please help.