I have a component that send data to a service to save data in DB. After that i want to redirect or navigate to a different component and show success message there. I have implement it but i always get the wrong value. I am also not sure if i have implement it correct.Any help is welcome. Here is my code.
Component class on submit etc {
.....
this.Service.updatePassword(this.neuesPassword); //this will call the updatepassword on service
//after it will navigate to and pass queryParams
this.router.navigateByUrl('/url',{ queryParams: { response: this.response } });
}
//this is the service method that is called
public updatePassword(newPass: string) {
let payload = new HttpParams();
payload = payload.set('Pass', newPass);
this.httpClient.post(this.URL_UPDATE_PASSWORD, { newPassword }).subscribe((response: boolean) => {
this.isSaved = response;
});
at the component i want to show the message i have on ngOnInit() { } method this
this.route.queryParams.subscribe(params => {
this._isChanged = params['response'];
});
and i want the _isChanged variable to get the value of the response. Something i am doing wrong . I have also look here send-data-through-routing-paths-in-angular
but i am doing something wrong. Any help wth that . thanks