📌  相关文章
📜  angular 9 如何获取先前的状态 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:41.537000             🧑  作者: Mango

代码示例1
//Update angular 6+
//The events.filter gives error because filter is not part of events, so change the code to

import { filter, pairwise } from 'rxjs/operators';

this.router.events
.pipe(filter((evt: any) => evt instanceof RoutesRecognized), pairwise())
.subscribe((events: RoutesRecognized[]) => {
  console.log('previous url', events[0].urlAfterRedirects);
  console.log('current url', events[1].urlAfterRedirects);
});