getParam utils
This commit is contained in:
parent
2ff807aaaa
commit
477e8ea5ae
@ -77,7 +77,7 @@ export abstract class EntitiesMapService<E extends Entity<I>, I> {
|
||||
}
|
||||
|
||||
replace(entities: E[]) {
|
||||
/** Return true if files were replaced or false if not **/
|
||||
/** Return true if entities were replaced or false if not **/
|
||||
const key = this._pluckPrimaryKey(entities[0]);
|
||||
const entityIds = entities.map(entity => entity.id);
|
||||
const existingEntities = this.get(key).filter(entity => entityIds.includes(entity.id));
|
||||
|
||||
@ -171,7 +171,14 @@ Array.prototype.filterTruthy = function <T>(this: T[], predicate: (value: T) =>
|
||||
/**
|
||||
* Use this in field initialization or in constructor of a service / component
|
||||
* @param param
|
||||
* @param route
|
||||
*/
|
||||
export function getParam(param: string): string | null {
|
||||
return inject(ActivatedRoute).snapshot.paramMap.get(param);
|
||||
export function getParam(param: string, route = inject(ActivatedRoute)): string | null {
|
||||
if (route.snapshot.paramMap.has(param)) {
|
||||
return route.snapshot.paramMap.get(param);
|
||||
}
|
||||
if (route.parent) {
|
||||
return getParam(param, route.parent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user