继承人我的路由器配置:使用儿童角2路由器指出抛出错误
import { RouterConfig } from '@angular/router';
...
export const AppRoutes : RouterConfig = [
{
path: '',
redirectTo: 'myview',
pathMatch: 'full'
},
{
path: 'myview',
component: ViewComponent,
children: [{
path: 'hello',
component: HelloComponent
}]
},
];
当我尝试加载页面我收到以下错误:
EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: ''
然而,当我做孩子路线的兄弟姐妹,像这样:
export const AppRoutes : RouterConfig = [
{
path: '',
redirectTo: 'myview',
pathMatch: 'full'
},
{
path: 'myview',
component: ViewComponent
},
{
path: 'hello',
component: HelloComponent
}
];
我能够正常加载页面没有任何错误。我究竟做错了什么?
为什么第一个孩子的路径设置为空字符串?这使得我的应用程序自动从页面根重定向到'HelloComponent'。 – dopatraman
你想怎么做呢? –
我在home组件中有一个链接,它将我发送给'ViewComponent'。然后我在'ViewComponent'中有一个连接到'HelloComponent'。 – dopatraman