Я пытался сделать эту работу, и я провел много исследований, но я не могу найти ответ. Я создаю приложение с несколькими маршрутами розетки в угловых 2 +.
У меня есть это:
App.Component.html
<div>
<div>
<nav mat-tab-nav-bar>
<a mat-tab-link
*ngFor="let link of navLinks"
[routerLink]="{ outlets: {form: link.path } }"
routerLinkActive="active-link" #rla="routerLinkActive"
[active]="rla.isActive">
<span><mat-icon>{{link.icon}}</mat-icon></span>
<span>{{link.label}}</span>
</a>
</nav>
<router-outlet name="form"></router-outlet>
</div>
</div>
<router-outlet></router-outlet>
app.module.ts
const appRoutes: Routes = [
{ path: 'home', component: HomeComponent,
children: [
{ path: "hotel", component: HotelSearchFormApiComponent, outlet:"form"},
{ path: "groups", component: GroupRequestFormComponent, outlet:"form"},
{ path: "flight", component: flightsSearchFormComponent, outlet:"form"},
{ path: "", component: HomeComponent},
//{ path: "", redirectTo: "hotel", pathMatch: "full" },
{ path: "**", redirectTo: "hotel" },
]
},
{ path: 'hotel/rate', component: RatesComponent },
{ path: 'hotel/:countryCod/:stateCod/:cityCod/:dateFrom/:dateTo', component: SearchHotelResultComponent },
App.component.ts
navLinks = [
{
path:'./home/hotel',
icon: 'hotel',
label: 'Hoteles'
},
{
path:'/home/flight',
icon:'flight',
label: 'Vuelos'
}
,
{
path:'./home/Package',
icon:'work',
label: 'Paquetes'
}
,
{
path:'./home/groups',
icon:'group',
label: 'Grupos'
}
]
Но когда я нажимаю на кнопку, я получаю эту проблему:
error: Error: Cannot match any routes. URL Segment: '/home/flight' at ApplyRedirects.push.../../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (http://localhost/a/vendor.js:140670:16) at CatchSubscriber.selector (http://localhost/a/vendor.js:140651:29) at CatchSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (http://localhost/a/vendor.js:181982:31) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26) at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18) at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (http://localhost/a/vendor.js:186715:26)
message: "Cannot match any routes. URL Segment: '/home/flight'"
stack: "Error: Cannot match any routes. URL Segment: '/home/flight'↵ at ApplyRedirects.push.../../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (http://localhost/a/vendor.js:140670:16)↵ at CatchSubscriber.selector (http://localhost/a/vendor.js:140651:29)↵ at CatchSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (http://localhost/a/vendor.js:181982:31)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (http://localhost/a/vendor.js:178721:26)↵ at MapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (http://localhost/a/vendor.js:178701:18)↵ at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (http://localhost/a/vendor.js:186715:26)"
__proto__: Object
id: 3
url: "/home(form:/home/flight)"
Кроме того, / Home не перенаправляет на дом / отель.
Раньше у меня была одна розетка, и я работал безупречно: (.
Заранее спасибо.
Андрес