1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How do I detect user navigating back in Angular2?

Discussão em 'Angular' iniciado por Michał Pietraszko, Outubro 7, 2024.

  1. I have a component and I need to detect if user pressed back button in his browser to navigate back.

    Currently I'm subscribing router events.

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

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

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

    });

    }


    I know that I can use window.onpopstate but it feels like a hack when using Angular2.

    Continue reading...

Compartilhe esta Página