相关疑难解决方法(0)

如何检测用户在Angular2中导航回来?

我有一个组件,我需要检测用户是否在他的浏览器中按下了按钮以导航回来.

目前我正在订阅路由器事件.

constructor(private router: Router, private activatedRoute: ActivatedRoute) {

    this.routerSubscription = router.events
        .subscribe(event => {

            // if (event.navigatesBack()) ...

        });

}
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用,window.onpopstate但在使用Angular2时感觉就像是黑客.

typescript angular2-routing angular

41
推荐指数
3
解决办法
5万
查看次数

标签 统计

angular ×1

angular2-routing ×1

typescript ×1