我已經設置了我的應用程序,因此我有一個Recipe Book
,它有一個列表Recipies
,當我單擊食譜時,它會在嵌套路線中顯示Recipe Details
。這也有一個按鈕,當點擊時在Recipes Details
內的嵌套路線中加載成分。Angular 2投擲錯誤:Outlet未啓動
到目前爲止,路由似乎工作,除非我嘗試導航到另一個Recipe
。如果Ingredients
托盤(路線)是活動的,那麼它會改變配方和摺疊Ingredients
路線,如果我再嘗試和導航(不打開配料)我收到以下錯誤:
Uncaught (in promise): Error: Outlet is not activated
Error: Outlet is not activated
它看起來像我的路由器需要Ingredients
才能激活,否則它不理解嵌套路由。這是我的承諾,但不知道如何解決它或當我錯了。
單食譜書,page.component.html
<app-tray class="recipe-list">
<app-recipe-list [recipe]="recipe"></app-recipe-list>
</app-tray>
<router-outlet></router-outlet>
偏方detail.component.html
<app-tray class="recipe">
The routing has worked and loaded recipe.
</app-tray>
<router-outlet></router-outlet>
成分,list.component.html
<app-tray class="ingredients-list">
Recipe Ingredients have loaded.
</app-tray>
個
app.routes.ts(更新)
export const routerConfig : Route[] = [
{
path: 'recipe-books',
children: [
{
path: ':id', component: SingleRecipeBookPageComponent,
children: [
{
path: 'recipes',
children: [
{ path: ':id', component: RecipeDetailComponent,
children: [
{ path: '', component: IngredientsListComponent },
{ path: 'ingredients', component: IngredientsListComponent }
]
},
{ path: 'new', component: IngredientsListComponent },
{ path: '', component: RecipeDetailComponent }
]
},
{ path: '', redirectTo: 'recipes', pathMatch: 'full' }
]
},
{ path: '', component: RecipeBooksPageComponent }
]
},
{ path: 'ingredients', component: IngredientsComponent },
{ path: '', redirectTo: 'recipe-books', pathMatch: 'full' },
{ path: '**', redirectTo: 'recipe-books', pathMatch: 'full' }
];
這些路線應該做什麼? –
您沒有將'pathMatch:'full''添加到2個空路徑子路由。你可以在Plunker中重現嗎? –
即使他們有一個組件,我應該仍然添加'pathMatch:full'? – Daimz