Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Route Start and Route End Events

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?

like image 500
Daniel Däschle Avatar asked Mar 07 '23 01:03

Daniel Däschle


1 Answers

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
        }
      }
    });
like image 70
Lucas Avatar answered Mar 27 '23 00:03

Lucas