Angular - Subscribe to route.queryParams -


i've got in ngoninit

ngoninit(): void {      this.sub = this.route.queryparams.subscribe((params: any) => {         this.data = {...params};         this.stationsservice.getstations(this.data).subscribe((res: any) => {             this.stations = res.data.stations         })     }); } 

and have delete function

deletemass() {     let array: = manipulateselections(this.selected, this.stations);     this.stationsservice.deletestations(array).subscribe((res: any) => {         this.data.random = math.random();         this.router.navigate([], {queryparams: this.data });     }) } 

what i'm doing. every time delete stations create random number change me route make first observable runs again. can suggest better way. seems bad practice.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -