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.
 
 
 
 
 

57 lines
1.4 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ActivatedRoute, ActivatedRouteSnapshot, Data, Params, RouterStateSnapshot } from '@angular/router';
export function allData(value: ActivatedRouteSnapshot | ActivatedRoute): Data {
let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value;
const result: { [key: string]: any } = {};
while (snapshot) {
for (const key in snapshot.data) {
if (snapshot.data.hasOwnProperty(key) && !result[key]) {
result[key] = snapshot.data[key];
}
}
snapshot = snapshot.parent;
}
return result;
}
export function allParams(value: ActivatedRouteSnapshot | ActivatedRoute): Params {
let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value;
const result: { [key: string]: any } = {};
while (snapshot) {
for (const key in snapshot.params) {
if (snapshot.params.hasOwnProperty(key) && !result[key]) {
result[key] = snapshot.params[key];
}
}
snapshot = snapshot.parent;
}
return result;
}
export function childComponent(value: RouterStateSnapshot) {
let current = value.root;
while (current) {
if (current.firstChild) {
current = current.firstChild;
} else {
break;
}
}
return current.component;
}