私のアプリケーションでは、3つのサブモジュール(AdminModule
,ChatModule
,ContactModule
)を持つSupportModule
があります。 SupportModule
とその3つのサブモジュールには独自のルーティングが定義されています。 SupportModule
ためAngular2 RC6 - ルーティング付きネストされたモジュール
import { AdminComponent } from './admin.component';
import { RssFeedsComponent } from './rssFeeds.component';
import { RssFeedDetailComponent } from './rssFeedDetail.component';
export const adminRoutes: Route =
{
path: 'admin',
component: AdminComponent,
children: [
{ path: '', component: RssFeedsComponent },
{ path: 'feeds', component: RssFeedsComponent },
{ path: 'feeddetail', component: RssFeedDetailComponent }
]
};
及びルーティング(3つのサブモジュールの親モジュールである):
構造
`AdminModule」のルーティングのようなものを以下に示す見えます以下に示す:
import { SupportComponent } from './support.component';
import { SupportNavComponent } from './support-nav.component';
//Feature Modules
import { chatRoutes } from './chat/chat.routing';
import { contactRoutes } from './contact/contact.routing';
import {adminRoutes} from './admin/admin.routing';
const supportRoutes: Routes = [
{
path: 'support',
component: SupportComponent,
children: [
{ path: '', component: SupportNavComponent },
chatRoutes,
contactRoutes,
adminRoutes
]
}
];
export const supportRouting: ModuleWithProviders = RouterModule.forChild(supportRoutes);
最後に私はこのsupportRouting
をAppModule
にインポートしています。
ナビゲーションは問題なく正常に動作しています。しかし、私は少し混乱しています。私はこれが、独自のルーティングを持つ親子モジュールを持つ正しい方法かどうか、またはこれを実現するためのより良い方法があるかどうかはわかりません。
誰かが私を訂正することができます(私が間違いをしている場合)またはより良いアプローチを知っていると、本当に役立ちます。
ディスカッションリンクは非常に役に立つと思われます。私はそれを調べますが、ここであなたの発見を共有してください。 –
クリスおかげで。私はまた、怠惰な読み込み後です。あなたの例はとても役に立ちます –