Collections
filterBy
Display records with an own property equal to a value.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { FilterByPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [FilterByPipe, JsonPipe],
template: `{{ [{"active":true},{"active":false}] | filterBy: "active": true | json }}`,
})
export class ExampleComponent {
}
Template
{{ [{"active":true},{"active":false}] | filterBy: "active": true | json }}
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: key, expected. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = [
{
"active": true
},
{
"active": false
}
] as const;
readonly parameter0 = "active";
readonly parameter1 = true;
{{ value | filterBy: parameter0: parameter1 | json }}
Rendered output
[
{
"active": true
}
]