I want to declare two Angular routes:
/items?id=SOME_ITEM_ID
)/items
)As the following isn't working, I want to know how I can define my routes to suite my needs?
export const routes: Routes = [
{ path: 'items?id=someItemId', component: ItemComponent },
{ path: 'items', component: AllItemsComponent },
];
I think you don't want queryParams but params, you should define your route like this :
export const routes: Routes = [
{ path: 'items/:id', component: ItemComponent },
{ path: 'items', component: AllItemsComponent },
];
As @cgTag says in comment, queryParams are transparent and you don't need to declare them in route definition.