2017-12-26 12 views
0

現在、私は現在アングル5で作業しています。私はルーターの設定とそれに応じたコンポーネントの内容の提示に問題点を見つけました。私のルータ構成は以下の通りです。角度2/4/5 - メインルータのアウトレットへの子コンポーネントのロード

const appRoutes: Routes = [ 
    { path: "", pathMatch: "full", redirectTo: "home" }, 
    { 
     path: "home", component: HomeComponent 
    }, 
    { 
     path: "applications", component: ApplicationsComponent, 
     children: [{ 
     path: ":applicationId/privacysettingsforapplications", component: PrivacysettingsforapplicationsComponent, 
     children: [ 
      { path: "", pathMatch: "full", redirectTo: "services" }, 
      { 
      path: "services", component: PrivacysettingsforapplicationservicesComponent 
      }, 
      { 
      path: "data", component: PrivacysettingsforapplicationdataComponent 
      }] 
     }] 
    }, 
    { 
     path: "devices", component: DevicesComponent, 
    }, 
    ]; 

私たちは一つのメイン<router-outlet></router-outlet>の角度負荷にその親コン​​ポーネントのすべてのコンテンツを持っています。ここではApplicationsComponentには子どもが1人あります。PrivacysettingsforapplicationsComponentには2人の子供(PrivacysettingsforapplicationservicesComponent and PrivacysettingsforapplicationdataComponent:サービスとデータ)があります。

子供が<router-outlet>の親の<router-outlet>の代わりに(PrivacysettingsforapplicationsComponent)の子をロードする方法があることを確認したいと思います。 さんの私がチェックした1つの方法は、子コンポーネントを親コンポーネントにピアとして配置することですが、ブレッドクラムモジュールはそのコンポーネントの実際の親が誰であるかを特定しません。PrivacysettingsforapplicationsComponent

答えて

-1

ルータパスの代わりにフルパスを指定する必要があります。例: パスラインアプリケーション/アプリケーション/サービスのプライベートセットを提供します。

上記の例のように正しいパスを指定する必要があります。

これにより、サービステンプレートは親の最もルータの出口にロードされます。

このヘルプが必要です。

0

path: "applications/:applicationId/privacysettingsforapplications"

パス

path: ":applicationId/privacysettingsforapplications"

+0

こんにちはサチン以下でこれを置き換え、あなたが示唆しているパスが正しいですが、それは、<ルータアウトレット>が必要です 'ApplicationComponent'でなく、私はそれを 'AppComponent'である親コンポーネントの中でロードしたい –

関連する問題