I need Previous URL in OnInit function of Angular TS file.
ngOnInit() {
this.router.events
.pipe(filter((e: any) => e instanceof RoutesRecognized),
pairwise()
).subscribe((e: any) => {
console.log(e[0].urlAfterRedirects); // previous url
});
}
I can get by above Code, but this Repeats multiple times, because I am having lot of child component under Parent. I need any other method, which runs only onces