[英]Angular Routing - redirectTo child route without path
I try to set a Child Route as default route that loads when i just enter the site address.我尝试将子路由设置为在我输入站点地址时加载的默认路由。
const routes: Routes = [
{path: '', pathMatch: 'full', redirectTo: ''},
{
path: '', component: FrameDefaultComponent,
children: [
{path: '', component: SiteCalculatorComponent}
]
},
];
But this dont work... When i give the SiteCalculatorComponent
any route like calc and redirect from level 1 to 'calc'
then it works.但这不起作用......当我给
SiteCalculatorComponent
任何路由,如 calc 并从级别 1 重定向到'calc'
然后它就可以工作了。 I know... But the point is that i want to load it "without" any path ;)我知道......但关键是我想在“没有”任何路径的情况下加载它;)
Is this possible?这可能吗? If yes how?
如果是如何?
I have one router like this:我有一个这样的路由器:
const firstRoutes: Routes = [ { path: '', children: [ { path: 'parent-url', children: secondRoutes } ] } ];
And second one like this:第二个是这样的:
export const secondRoutes: Routes = [ { path: '', children: [ { path: '', redirectTo: 'child-route', pathMatch: 'full' }, { path: 'child-route', component: ChildComponent } ] } ];
My ChildComponent can be called with /child-route or /parent-url/child-route.我的 ChildComponent 可以用 /child-route 或 /parent-url/child-route 调用。 I want to disable calling my function with both routs, so to set able to call it only with /parent-url/child-route.
我想禁用使用两个路由调用我的函数,因此设置只能使用 /parent-url/child-route 调用它。
I dont know how to check if there is /parent-url and if it is not there to disable calling ChildComponent without that /parent-url .我不知道如何检查是否有 /parent-url ,如果没有,则在没有 /parent-url 的情况下禁用调用 ChildComponent 。 in whole url?
在整个网址?
The solution:解决方案:
{
path: '', component: FrameDefaultComponent,
children: [
{path: '', component: SiteCalculatorComponent}
]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.