0.0.2 • Published 4 years ago

ngx-nprogress v0.0.2

Weekly downloads
9
License
-
Repository
-
Last release
4 years ago

ngx-nprogress

This project is a angular wrapper for nprogress, see this demo: http://ricostacruz.com/nprogress/

Usage

import { NgxNProgressService } from 'ngx-nprogress';

@Component({ ... })
export class AppComponent implements OnInit {

  constructor(
      private readonly router: Router,
      private readonly progressService: NgxNProgressService,) {

  }

  public ngOnInit() {
    this.router.events
      .pipe(tap(event => {
        if(event instanceof NavigationStart) {
          this.nprogressService.start();
        } else if(event instanceof NavigationEnd) {
          this.nprogressService.done();
        } else if(event instanceof NavigationError) {
          this.nprogressService.done();
        } else if(event instanceof NavigationCancel) {
          this.nprogressService.done();
        }
      }))
      .subscribe();
  }

}