Я установил свое приложение, так что у меня есть Recipe Book
, который имеет список Recipies
, который, когда я нажимаю на Рецепт, затем показывает Recipe Details
по вложенному маршруту. Это также имеет кнопку, которая при нажатии загружает ингредиенты по вложенному маршруту внутри Recipes Details
.Ошибка угла отклонения: выход не активирован
Пока что работа маршрутизации, за исключением случаев, когда я пытаюсь перейти к другому Recipe
. Если Ingredients
лоток (маршрут) активен, то он изменит рецепт и свернуть 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