I need to access the current url with query params using an activate router.
constructor(private router: Router,
private route: ActivatedRoute) {
}
ngOnInit() {
this.router.events.pipe(
filter((event: RouterEvent) => event instanceof NavigationEnd && event.url.startsWith('/resources'))
).subscribe(() => {
console.log(this.route.snapshot.params)
})
}
When I access my url, http://localhost:4200/web/#/resources/sharepoint;siteId=docs;displayName=test;resourceId=4
this.route.snapshot.params
prints an empty array. How can I access the query param "resourceId"?
I have tried this.route.snapshot.queryParams
and still it prints an empty array.
read with this.router.url
then split it
constructor(private router: Router) {
var url=this.router.url;
var params=url.split(";");
var resourceId=params[params.length-1].split("=")[1];
}