0
田地使用最新版本的角2路玩,我注意到,在下方加入不是一個孩子的路線原因/管理員上班路線角2路由,增加孩子的路線導致路由無法工作
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AdminComponent } from './admin.component';
import {AdminChildComponent} from './admin-child.component';
import {productRoutes} from "../product/product.routes";
export const adminRoutes : Routes =[
{
path: 'admin', component: AdminComponent,
children:[
{path:"/child", component:AdminChildComponent}
]
}
];
export const adminRouting: ModuleWithProviders = RouterModule.forChild(adminRoutes);
一旦我下面去掉,應用wors就好了,只要我添加它,我得到的控制檯錯誤
EXCEPTION: Uncaught (in promise): Error: Cannot match any routes: 'admin'
children:[
{path:"/child", component:AdminChildComponent}
]
需要幫助的可能理解爲什麼我得到這個錯誤。完全混淆。
我不明白爲什麼需要這樣的配置。儘管如此,添加你建議的{path:'',...}會產生一個異常EXCEPTION:未捕獲(承諾):錯誤:無法匹配任何路由:'child' – iswak
我在回答中給出瞭解釋爲什麼這樣的路由是必需的。 – micronyks
我理解你的解釋,並將你的答案考慮在內,並與其他具有兒童路線的路線進行比較。是的,看起來你總是需要一條空的路線,或者重定向或者路由到一個組件。我的問題是「/孩子」而不是「孩子」 – iswak