Also hat ich eine Modulstruktur wie diese:Angular 2 einen weiteren „Geschwister“ Modul einge spritzt die falsche Komponente
app
----pages
---------dashboard
---------posts
Beide dashboard
und posts
ihr eigenes Routing haben.
Hier ist, wie das Routing wie folgt aussieht:
Seiten
const routes: Routes = [
{
path: '',
component: Pages,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', loadChildren: './dashboard#DashboardModule' }
{ path: 'posts', loadChildren: './posts#PostsModule' }
]
}
];
export const routing = RouterModule.forChild(routes);
Armaturenbrett
const routes: Routes = [
{
path: '',
component: DashboardComponent
}
];
export const routing = RouterModule.forChild(routes);
Beiträge
Alles funktioniert gut, aber wenn ich versuche, die PostsModule
im DashboardModule
wie diese zu importieren:
import { PostsModule } from '../posts';
@NgModule({
imports: [
routing, // Dashboard routes
CommonModule,
...
PostsModule
]
})
export class DashboardModule { }
und Last http://localhost:3000/#/dashboard
, zeigt es die PostsComponent
, statt DashboardComponent
, nur weil ich die „Geschwister importiert "Modul
Wie kann ich das beheben?