2017-08-25 5 views
1

Ich habe folgende App Route Konfiguration:Angular 4.X: Initialisieren Kind Komponenten Router

const routes: Routes = [ 
    {loadChildren: './modules/faq/faq.module', path: 'faq'}, 
    {loadChildren: './modules/pagination/pagination.module', path: 'page'}, 
    {loadChildren: './modules/appointmentAgreement/appointmentAgreement.module#AppointmentAgreementModule', path: 'terminvereinbarung'} 
]; 

Und die appointmentAgreement Kind Module Wegekonfiguration

const appointmentAgreementRoutes: Routes = [{ 
    path: '', 
    children: [ 
     {path: 'thema', component: TopicSectionComponent}, 
     {path: 'filiale', component: BranchSectionComponent}, 
     {path: 'termin', component: DatetimeSectionComponent}, 
     {path: 'daten', component: PersonalDataSectionComponent}, 
     {path: 'bestaetigung', component: ConfirmationSectionComponent}, 
    ] 
}]; 

Jetzt i die Anwendung wollen umleiten zu/terminvereinbarung/thema wenn seite/terminvereinbarung geöffnet ist.

Wie kann ich das erreichen?

Vielen Dank im adcance.

Antwort

1

alle Routing halten, wie es gerade bei Kindern in Submodul

diese Umleitung versuchen fügt
const appointmentAgreementRoutes: Routes = [{ 
path: '', 
children: [ 
    { path: '', redirectTo: 'thema', pathMatch: 'full' }, 
    {path: 'thema', component: TopicSectionComponent}, 
    {path: 'filiale', component: BranchSectionComponent}, 
    {path: 'termin', component: DatetimeSectionComponent}, 
    {path: 'daten', component: PersonalDataSectionComponent}, 
    {path: 'bestaetigung', component: ConfirmationSectionComponent}, 
] 
}]; 
+0

Awesome, tat dies der Trick. Dank! – user3507003

1

Versuchen Sie, die folgenden in appointmentAgreement Komponente zu tun:

const appointmentAgreementRoutes: Routes = [{ 
{ 
    path: 'terminvereinbarung', 
    redirectTo: 'thema', 
    pathMatch: 'full' 
}, 
{ 
    path: 'terminvereinbarung', 
    component: TopicSectionComponent, 
} 
children: [ 
    {path: 'thema', component: TopicSectionComponent}, 
    {path: 'filiale', component: BranchSectionComponent}, 
    {path: 'termin', component: DatetimeSectionComponent}, 
    {path: 'daten', component: PersonalDataSectionComponent}, 
    {path: 'bestaetigung', component: ConfirmationSectionComponent}, 
] 

}];

+0

vielen Dank für diese schnelle Antwort. Es sieht so aus, als hätten Sie ein Syntaxproblem in Ihrem Snippet. Kannst du den richtigen geben? – user3507003

+0

Ich habe meine Antwort aktualisiert und geschweifte Klammer um den Pfad –

+0

Ich habe versucht, Ihre aktualisierte Lösung, aber es funktioniert leider nicht. Aufruf/terminvereinbarung macht keine Komponente Aufruf/terminvereinbarung/theme gibt einen Fehler: Fehler: Kann keine Routen übereinstimmen. URL Segment: ‚Terminvereinbarung/Thema – user3507003