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.
 
 
 
 
 

40 lines
986 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Directive, HostListener, Input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Directive({
selector: '[sqxTabRouterLink]',
})
export class TabRouterlinkDirective {
@Input('sqxTabRouterLink')
public commands: any[];
constructor(
private readonly router: Router,
private readonly route: ActivatedRoute,
) {
}
@HostListener('click', ['$event'])
public onClick(event: MouseEvent) {
const escaped = this.commands.map(x => encodeURIComponent(x));
const urlTree = this.router.createUrlTree(escaped, {
relativeTo: this.route,
});
if (event.ctrlKey) {
const url = this.router.serializeUrl(urlTree);
window.open(url, '_blank');
} else {
this.router.navigateByUrl(urlTree);
}
}
}