2017-08-29 8 views
0

ルータの子オブジェクトを取得するにはどうすればよいですか?ルートの子を取得する方法

const appRoutes: Routes = [ 
    { 
     path: 'parameters', 
     component: AsideComponent, 
     children: [ 
      { path: '', component: ParametersComponent }, 
      { path: 'crypto-accounts', component: ParametersCryptoAccountsComponent }, 
      { path: 'withdrawal-accounts', component: ParametersWithdrawalAccountsComponent }, 
      { path: 'add-withdrawal-account', component: ParametersAddWithdrawalAccountComponent } 
     ] 
    }, 
    ... 
] 

とコンポーネント

export class AsideComponent implements OnInit { 
    constructor(private router: Router) { 
     let children = this.router... ? // <----- 
    } 
} 

私はthis.routerを持って、どのように私は、現在の状態の子供を得ることができますか?

+1

は必要ですか? –

+0

私はそれのための脇のメニュー、同じリンクを作る必要があります –

+0

あなたはそれに必要な情報は? –

答えて

1

あなたはこれらの子供たちへのアクセスが必要なのですかどのような目的のためにhttps://angular.io/api/router/ActivatedRoute

export class AsideComponent implements OnInit { 
    constructor(private router: ActivatedRoute) { 
     let children = this.router.children 
    } 
} 
+0

なぜこの長さが1か分かりますか?私は子供の中に道があるので思ったが、親の長さも1である。 –

+1

リンクをありがとう、this.activatedRoute.routeConfig.childrenとして解決しました –

関連する問題