mirror of https://github.com/Squidex/squidex.git
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.
43 lines
1.1 KiB
43 lines
1.1 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Sebastian Stehle. All rights reserved
|
|
*/
|
|
|
|
import { ActivatedRoute, ActivatedRouteSnapshot, Data, Params } from '@angular/router';
|
|
|
|
export function allData(value: ActivatedRouteSnapshot | ActivatedRoute): Data {
|
|
let snapshot: ActivatedRouteSnapshot = value['snapshot'] || value;
|
|
|
|
const result: { [key: string]: any } = { };
|
|
|
|
while (snapshot) {
|
|
for (let 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 = value['snapshot'] || value;
|
|
|
|
const result: { [key: string]: any } = { };
|
|
|
|
while (snapshot) {
|
|
for (let key in snapshot.params) {
|
|
if (snapshot.params.hasOwnProperty(key) && !result[key]) {
|
|
result[key] = snapshot.params[key];
|
|
}
|
|
}
|
|
|
|
snapshot = snapshot.parent;
|
|
}
|
|
|
|
return result;
|
|
}
|