# wrList

> Join a list with the commas and the last "and" or "or" of the app locale.

Source: https://ngwr.dev/reference/pipes/wr-list  
Kind: Pipe  
Added in v16.9  
Optional

## Installation

Import the class. This entry point has no stylesheet.

```typescript
import { Component } from '@angular/core';
import { WrList, wrFormatList } from 'ngwr/pipes';

@Component({ imports: [WrList] })
export class MyComponent {}
```

## Basic usage

`join(', ')` drops the last word and is wrong in every language. The pipe joins through `Intl.ListFormat` in `LOCALE_ID`.

```angular-html
<p>{{ names | wrList }}</p>
<p>{{ names | wrList: 'disjunction' }}</p>
<p>{{ parts | wrList: 'unit' }}</p>
<p>{{ parts | wrList: { type: 'unit', style: 'narrow' } }}</p>
```

```angular-ts
import { Component } from '@angular/core';

import { WrList } from 'ngwr/pipes';

@Component({
  selector: 'app-team',
  templateUrl: './team.html',
  imports: [WrList],
})
export class Team {
  protected readonly names = ['Ada', 'Alan', 'Grace'];
  protected readonly parts = ['5 kg', '200 g'];
}
```

## Playground

Blank items are left out. One item renders as it is, none as an empty string.

```angular-html
{{ items | wrList: { type: 'conjunction', style: 'long' } }}
```

```angular-ts
import { Component } from '@angular/core';

import { WrList } from 'ngwr/pipes';

/**
 * Playground
 */
@Component({
  selector: 'wrlist-playground-example',
  templateUrl: './wrlist-playground-example.html',
  imports: [WrList],
})
export class WrlistPlaygroundExample {
  // Stubs. The page owned these values; the snippet shows the markup
  // that reads them, not where they come from.
  protected items: any = null;
}
```

## In TypeScript

`wrFormatList` gives the same text for a string built in code, in the locale you pass.

```angular-ts
import { wrFormatList } from 'ngwr/pipes';

wrFormatList(['Ada', 'Alan', 'Grace'], 'en-GB');                // "Ada, Alan and Grace"
wrFormatList(['Ada', 'Alan', 'Grace'], 'en-GB', 'disjunction'); // "Ada, Alan or Grace"
wrFormatList(['Ада', 'Алан', 'Грейс'], 'ru');                   // "Ада, Алан и Грейс"
```

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `wrList` | Joins the items through `Intl.ListFormat` in `LOCALE_ID`. Takes a type shortcut or the full options object. Blank items are left out; `null`, `undefined` and an empty list give an empty string. | `(value: Iterable<string> \| null \| undefined, typeOrOptions: WrListType \| Intl.ListFormatOptions = 'conjunction') => string` | `-` |
| `wrFormatList` | The pipe as a function, in the locale given. | `(value: Iterable<string> \| null \| undefined, locale: string, typeOrOptions: WrListType \| Intl.ListFormatOptions = 'conjunction') => string` | `-` |
| `WrListType` | What joins the last item: "and", "or", or nothing, for a compound unit. | `'conjunction' \| 'disjunction' \| 'unit'` | `'conjunction'` |
| `options.style` | How much of the joining word is written, as `Intl.ListFormat` reads it. | `'long' \| 'short' \| 'narrow'` | `'long'` |

## See also

- [wrPlural](https://ngwr.dev/reference/pipes/wr-plural) — Pick the right word form for a count, in any language.
- [wrNumber](https://ngwr.dev/reference/pipes/wr-number) — Format a number, percent or price in the app locale.
- [Interpolation](https://ngwr.dev/guides/translations/interpolation) — Fill placeholders in a translation with values.
