Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { Router, ActivatedRouteSnapshot, NavigationEnd } from '@angular/router';
- import { Title } from '@angular/platform-browser';
- import {Angulartics2Piwik} from "angulartics2/piwik";
- @Component({
- selector: 'jhi-main',
- templateUrl: './main.component.html'
- })
- export class JhiMainComponent implements OnInit {
- constructor(private titleService: Title, private router: Router, private angulartics2Piwik: Angulartics2Piwik) {}
- private getPageTitle(routeSnapshot: ActivatedRouteSnapshot) {
- let title: string =
- routeSnapshot.data && routeSnapshot.data['pageTitle'] ? routeSnapshot.data['pageTitle'] : 'jhipsterangularticsApp';
- if (routeSnapshot.firstChild) {
- title = this.getPageTitle(routeSnapshot.firstChild) || title;
- }
- return title;
- }
- ngOnInit() {
- this.router.events.subscribe(event => {
- if (event instanceof NavigationEnd) {
- this.titleService.setTitle(this.getPageTitle(this.router.routerState.snapshot.root));
- }
- });
- this.angulartics2Piwik.startTracking();
- }
- }
Add Comment
Please, Sign In to add comment