Headless CMS and Content Managment Hub
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.
 
 
 
 
 

47 lines
1.3 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
// tslint:disable: readonly-array
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TitleService, Types } from '@app/framework/internal';
@Component({
selector: 'sqx-title[message]',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TitleComponent implements OnDestroy, OnChanges {
private previousIndex: undefined | number;
@Input()
public url: any[] = ['./'];
@Input()
public message: string;
constructor(
private readonly route: ActivatedRoute,
private readonly router: Router,
private readonly titleService: TitleService,
) {
}
public ngOnChanges() {
const routeTree = this.router.createUrlTree(this.url, { relativeTo: this.route });
const routeUrl = this.router.serializeUrl(routeTree);
this.previousIndex = this.titleService.push(this.message, this.previousIndex, routeUrl);
}
public ngOnDestroy() {
if (Types.isNumber(this.previousIndex)) {
this.titleService.pop();
}
}
}