Laten we dit eens lekker standalone proberen te maken
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.component.ts 987B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Component } from '@angular/core';
  2. import { SlimLoadingBarService } from 'ng2-slim-loading-bar';
  3. import {
  4. NavigationCancel,
  5. Event,
  6. NavigationEnd,
  7. NavigationError,
  8. NavigationStart,
  9. Router
  10. } from '@angular/router';
  11. @Component({
  12. selector: 'app-root',
  13. templateUrl: './app.component.html',
  14. styleUrls: ['./app.component.scss']
  15. })
  16. export class AppComponent {
  17. title = 'eos-beacon';
  18. constructor(private _loadingBar: SlimLoadingBarService, private _router: Router) {
  19. this._router.events.subscribe((event: Event) => {
  20. this.navigationInterceptor(event);
  21. });
  22. }
  23. private navigationInterceptor(event: Event): void {
  24. if (event instanceof NavigationStart) {
  25. this._loadingBar.start();
  26. }
  27. if (event instanceof NavigationEnd) {
  28. this._loadingBar.complete();
  29. }
  30. if (event instanceof NavigationCancel) {
  31. this._loadingBar.stop();
  32. }
  33. if (event instanceof NavigationError) {
  34. this._loadingBar.stop();
  35. }
  36. }
  37. }