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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -