Guest User

Untitled

a guest
Oct 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { Router, ActivatedRouteSnapshot, NavigationEnd } from '@angular/router';
  3.  
  4. import { Title } from '@angular/platform-browser';
  5. import {Angulartics2Piwik} from "angulartics2/piwik";
  6.  
  7. @Component({
  8. selector: 'jhi-main',
  9. templateUrl: './main.component.html'
  10. })
  11. export class JhiMainComponent implements OnInit {
  12. constructor(private titleService: Title, private router: Router, private angulartics2Piwik: Angulartics2Piwik) {}
  13.  
  14. private getPageTitle(routeSnapshot: ActivatedRouteSnapshot) {
  15. let title: string =
  16. routeSnapshot.data && routeSnapshot.data['pageTitle'] ? routeSnapshot.data['pageTitle'] : 'jhipsterangularticsApp';
  17. if (routeSnapshot.firstChild) {
  18. title = this.getPageTitle(routeSnapshot.firstChild) || title;
  19. }
  20. return title;
  21. }
  22.  
  23. ngOnInit() {
  24. this.router.events.subscribe(event => {
  25. if (event instanceof NavigationEnd) {
  26. this.titleService.setTitle(this.getPageTitle(this.router.routerState.snapshot.root));
  27. }
  28. });
  29. this.angulartics2Piwik.startTracking();
  30. }
  31. }
Add Comment
Please, Sign In to add comment