4

How can i get access to the routing start and routing end events? I want to show a Progress Bar while routing and loading data.

Can someone tell me how this works?

Daniel Däschle
  • 766
  • 10
  • 32

1 Answers1

7

If you prefer to work with an observable:

import { Router, NavigationStart } from '@angular/router';
...
    constructor(router:Router) {
      router.events.subscribe(e => {
        if(e instanceof NavigationStart) {
          // Init Code
        }

        if(e instanceof NavigationEnd) {
          // Exit Code
        }
      }
    });
Lucas
  • 9,871
  • 5
  • 42
  • 52