Angular2 路由器不会更改组件

Angular2 router doesn't change component

我有 1 个组件,我想为不同的路由器重用 links 路由看起来像:

{ path: '', component: OddComponent },
{ path: 'sport/:id', component: OddComponent },
{ path: 'sport/:id/category/:categoryid', component: OddComponent }

该组件需要从每个路由器的不同位置获取 link。问题是组件订阅了一项服务,现在每次我导航到不同的路由器 link 时,订阅都会堆积起来。我该如何解决这个问题?

您可以在更改路由之前使用 onDestroy 挂钩取消订阅服务 ...

for more details