app.component.ts 1017 B

1234567891011121314151617181920212223242526272829303132
  1. import { Component, OnInit, Renderer2, ElementRef } from '@angular/core';
  2. import { Router, NavigationEnd } from '@angular/router';
  3. import { filter } from 'rxjs/operators';
  4. import { TitleService } from '@delon/theme';
  5. import { VERSION as VERSION_ALAIN } from '@delon/theme';
  6. import { VERSION as VERSION_ZORRO, NzModalService } from 'ng-zorro-antd';
  7. @Component({
  8. selector: 'app-root',
  9. template: `
  10. <router-outlet></router-outlet>
  11. `,
  12. })
  13. export class AppComponent implements OnInit {
  14. constructor(
  15. el: ElementRef,
  16. renderer: Renderer2,
  17. private router: Router,
  18. private titleSrv: TitleService,
  19. private modalSrv: NzModalService,
  20. ) {
  21. renderer.setAttribute(el.nativeElement, 'ng-alain-version', VERSION_ALAIN.full);
  22. renderer.setAttribute(el.nativeElement, 'ng-zorro-version', VERSION_ZORRO.full);
  23. }
  24. ngOnInit() {
  25. this.router.events.pipe(filter(evt => evt instanceof NavigationEnd)).subscribe(() => {
  26. this.titleSrv.setTitle();
  27. this.modalSrv.closeAll();
  28. });
  29. }
  30. }