I have tried to redirect the page after getting data successfully deleted. So I put the redirect router.navigate inside of the subscribe of the data section. But it's not working and also I have tried with ngZone also nothing happens. And I want to show the success message also. How can I show that?
without ngZone:
const rid = params['rid'];
this.roleSer.deleteRole(rid).subscribe(
data => { this.router.navigate(['viewroles']) },
error => { error }
);
});
with ngZone:
const vrid = this.route.params.subscribe((params: Params) => {
const rid = params['rid'];
this.roleSer.deleteRole(rid).subscribe(
data => { this.zone.run(()=>{
this.router.navigate(['viewroles'])
}); },
error => { error }
);
});
Create one redirect function and use it
const vrid = this.route.params.subscribe((params: Params) => {
const rid = params['rid'];
this.roleSer.deleteRole(rid).subscribe(
data => {
this.redirect('viewroles');
},
error => { error }
);
});
redirect(path): void {
this.router.navigate(['/' + path])
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With