私は、これらのルートは子ルートのparam変更をサブスクライブするにはどうすればいいですか?
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{
path: 'explore',
component: ExploreComponent,
children: [
{ path: '', component: ProductListComponent },
{ path: ':categorySlug', component: ProductListComponent }
]
}
];
これにより、ユーザは
/explore
(なしカテゴリ)
または
/explore/computers
(カテゴリcomputers
)から
に行くことができることを意味してい親(ExploreComponent
)、私は欲しいo categorySlug
param変更を購読して、もちろんイベントを処理できます。これどうやってするの?
EDIT:
this.activatedRoute.firstChild.params.subscribe(console.log);
をそして、それは私が欲しいものを正確に私を与えるが、私は(カテゴリなし)/explore
に行くたら、それは死ぬ:
私が使用してサブスクライブしてみました。それは/explore/:categorySlug
リンクを使用してナビゲートする場合にのみ機能します。
はい、NULLかどうか確認しています。 –
これは1回だけ印刷されます。 –
@FeloVilches一度はどういう意味ですか?あなたはその状況についてもっと説明できますか? – mok