Here is my use case:
When I load url / product / 123, I want to download the ProductComponent component
This is my setup:
RouterModule.forRoot([
{
path: 'product/:productId',
component: ProductComponent
},
{
path: '**', component: NotFoundComponent
},
]),
Now I have added a recognizer to check if this product identifier exists, so my setup looks like this:
RouterModule.forRoot([
{
path: 'product/:productId',
component: ProductComponent,
resolver: {
productResolver: ProductResolver
}
},
{
path: '**', component: NotFoundComponent
},
]),
My resolver checks if this parameter productId exists through an api call. The problem is that when the productId is not found, I want to load NotFoundComponent and not redirect to another page (I don't want to change the URL, for example, angular 2).
Does anyone know how to do this? if not productId found via loading resolver NotFoundComponent without changing url / navigation?