私はRecipe Book
を持っているので、Recipies
のリストを持っています。レシピをクリックすると、ネストされたルートにRecipe Details
が表示されます。これには、ボタンをクリックすると、Recipes Details
内のネストされたルートの成分が読み込まれます。角度2投げエラー:アウトレットがアクティブ化されていません
これまでのところ、別の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' }
];
これらのルートはどのようなものですか? –
2つの空のパスの子ルートに 'pathMatch: 'full''を追加しませんでした。 Plunkerで再現できますか? –
コンポーネントがあっても 'pathMatch:full'を追加する必要がありますか? – Daimz