我在角度2中遇到了一个路由问题,我花了将近一天的时间试图找出问题所在,
这是我的appmodule路由配置
RouterModule.forRoot([
{ path: "Dashboard", component: DashBoardComponent, children: [
{
path: "BenchMark", component: BenchmarkPortalComponent, outlet:"portals",children: [
{ path: "pendingAccounts", component: PendingAccounts, outlet: "contacts" },
{ path: "acceptedAccounts", component: AcceptedAccounts, outlet : "contacts" },
{ path: "", component: BenchmarkPortalComponent },
]
},
{ path: "", component: DashBoardComponent },
]},
{ path: '', redirectTo: 'DashBoard', pathMatch: 'full' }
])],
我的appcomponent有一个routeroutlet,Dashboard组件有一个命名路由器插座(name =“portals”),而homecomponent有一个名为routeroutlet(name =“contacts”)
但是当我加载页面时,我看到应用程序组件已加载,然后我出现错误
core.umd.js:3491EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 't'
Error: Cannot find primary outlet to load 't'
at getOutlet (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4342:21)
at ActivateRoutes.activateRoutes (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4183:49)
at eval (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4128:60)
at Array.forEach (native)
at ActivateRoutes.activateChildRoutes (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4128:31)
at ActivateRoutes.activateRoutes (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4193:28)
at eval (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4128:60)
at Array.forEach (native)
at ActivateRoutes.activateChildRoutes (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4128:31)
at ActivateRoutes.activate (http://localhost:59784/node_modules/@angular/router/bundles/router.umd.js:4102:16)
我不确定我在这里缺少什么。请帮忙。我使用角2.3.1