Utilities
getPath
Read an own-property path supplied as a key array.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { GetPathPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [GetPathPipe],
template: `{{ data | getPath: ["profile", "name"] }}`,
})
export class ExampleComponent {
readonly data = { profile: { name: "Ana" } };
}
Template
{{ data | getPath: ["profile", "name"] }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: path, fallback. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = {
"profile": {
"name": "Ana"
}
} as const;
readonly parameter0 = ["profile","name"] as const;
{{ value | getPath: parameter0 }}
Rendered output
Ana