← All pipes
Collections

partition

Split records into matching and remaining buckets.

Use it in your component

Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { PartitionPipe } from 'extra-pipe';

@Component({
  standalone: true,
  imports: [PartitionPipe, JsonPipe],
  template: `{{ [{"active":true},{"active":false}] | partition: "active": true | json }}`,
})
export class ExampleComponent {

}

Template
{{ [{"active":true},{"active":false}] | partition: "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 | partition: parameter0: parameter1 | json }}

Rendered output

{
  "matching": [
    {
      "active": true
    }
  ],
  "remaining": [
    {
      "active": false
    }
  ]
}