[英]exclude specific path from routing in angular 2+
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.但是现在在一个页面上,有一个链接(
<a href="/help/en/index.html" target="_blank">
)指向帮助页面,这些页面是托管在同一台服务器上的静态资源。 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?假设我们不能在另一个域中托管帮助资源,有没有办法从角度路由中排除
/help/**
路径? or do you think this is a valid feature request for angular to support?或者您认为这是 angular 支持的有效功能请求吗?
As mentioned here angular 2 exclude url in routing the only solution seems to set useHash: true
in your RouterModule config:正如这里提到的angular 2 exclude url in routing唯一的解决方案似乎是在你的 RouterModule 配置中设置
useHash: true
:
@NgModule({
imports: [
RouterModule.forRoot(
[
{
path: 'login',
loadChildren: './login/login.module#LoginModule'
},
{
path: '**',
redirectTo: ''
},
],
{
useHash: true,
onSameUrlNavigation: 'reload'
}
)
],
exports: [RouterModule]
})
export class AppRoutingModule { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.