@Pipe

This is the documentation for Angular 8.
You can switch to the latest version Angular 9.

A pipe takes in data as input and transforms it to a desired output.

Example

Here's a custom pipe that doubles a value:

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({name: 'double'})
export class DoublePipe implements PipeTransform {
  transform(value: number): number {
    return value * 2;
  }
}

Usage:

{{ value | double }} 

Options

name#

name: string

The pipe name to use in template bindings.

pure#

pure?: boolean

When true, the pipe is pure, meaning that the transform() method is invoked only when its input arguments change. Pipes are pure by default.

If the pipe has internal state (that is, the result depends on state other than its arguments), set pure to false. In this case, the pipe is invoked on each change-detection cycle, even if the arguments have not changed.