My angular route config is as below:
export const routes: Routes = [
{ path: 'mgmt', ... },
{ path: 'about', ... },
{ path: '**', component: PageNotFoundCmp }
];
But now on a page, there's a link (<a href="/help/en/index.html" target="_blank">
) to help pages, which are static resources hosted on the same server. With the above route config, apparently it will be matched to others **
- page not found.
Let's say we cannot host help resources in another domain, is there any way to exclude /help/**
path from angular routing? or do you think this is a valid feature request for angular to support?
As mentioned here angular 2 exclude url in routing the only solution seems to set useHash: true
in your RouterModule config:
@NgModule({
imports: [
RouterModule.forRoot(
[
{
path: 'login',
loadChildren: './login/login.module#LoginModule'
},
{
path: '**',
redirectTo: ''
},
],
{
useHash: true,
onSameUrlNavigation: 'reload'
}
)
],
exports: [RouterModule]
})
export class AppRoutingModule { }