Can't navigate to child route with queryParams by Angular.Router.navigate
Аlready tried:
this.router.navigateByUrl('/desktop/search?q=folder'));
this.router.navigate(['desktop', 'search'], { queryParams: {q: 'folder'} });
this.router.navigate(['desktop/search'], { queryParams: {q: 'folder'} });
my routes:
{
path: 'desktop',
component: FavoritesPageComponent,
children: [
{ path: 'desktop-admin', component: DesktopAdminComponent },
{ path: 'favorites', component: FavoritesBodyMainComponent },
{ path: 'sessions', component: SessionsComponent },
{ path: 'search', component: FavoritesBodySearchComponent },
{ path: 'shared_with_me', component: FavoritesBodySharedComponent },
{ path: 'recycle', component: FavoritesBodyRecycleComponent }
]
}
when i try to navigate to 'desktop/search?q=folder' i've got the following error:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'desktop/search%3Bq%3D%25D0%25BF%25D0%25B0%25D0%25BF%25D0%25BA%25D0%25B0'
What's wrong? Is there a way to use child routes with normal queryParams like
.../desktop/search?q=folder
this.route.queryParams.subscribe(params => {
console.log('params['q']: ', params['q']);
});
Look at this example:
1- Declaring route parameters:
to see the product details page for product with ID 10, you must use the following URL:
2- Linking to routes with parameters:
or
3- Reading route parameters:
I hope this helps you.