I have application with routing, which changes by buttons click (see screen below). I'm trying to get URL into text box every time it's changes. How to do it? So far I been able to attach to ActivatedRoute.queryParams , but it fires only if there are parameter change, and do not work without parameter.
// could you help to fix this code?
url$ = this.activatedRoute.queryParams.pipe(
map(() => {
console.log("router.url="+this.router.url); // full URL with params
return this.router.url.split('?')[0] ;
})
)
I'm changing pages by button click code:
btnGoProducts(name?: string){
if (name)
this.router.navigate(['/products'], {queryParams: {name: name}});
else
this.router.navigate(['/products']);
}
Only right buttons on this screen works (because subscription on the parameters change):
Page code: app.component.ts Whole test app: github.com/sam-klok/AngularPlayRoutes