角度路由器激活事件

时间:2018-02-22 14:50:59

标签: angular angular-routing

我想听Angular路由器事件,但只是第一次激活它们。

所以给出以下场景:A > B。如果我要听ActivationEnd事件,A和B都会被解雇(如预期的那样)。

现在,如果我要导航到A > B > C内的子路由,现在A BC ActivationEnd将再次触发。我只希望C这次开火。

这就是路由器在路由器解析器下工作的方式,我想基本上做这种行为。我的代码如下所示:

this.router.events.pipe(
  tap((event) => console.log(event)),
  filter(event => event instanceof ActivationEnd)
).subscribe((event: ActivationEnd) => { ... })

0 个答案:

没有答案