Angular 2Pipes


Introduction

The pipe | character is used to apply pipes in Angular 2. Pipes are very similar to filters in AngularJS in that they both help to transform the data into a specified format.

Parameters

Function/ParameterExplanation
@Pipe({name, pure})metadata for pipe, must immediately precede pipe class
name: stringwhat you will use inside the template
pure: booleandefaults to true, mark this as false to have your pipe re-evaluated more often
transform( value, args[]? )the function that is called to transform the values in the template
value: anythe value that you want to transform
args: any[]the arguments that you may need included in your transform. Mark optional args with the ? operator like so transform(value, arg1, arg2?)

Remarks

This topic covers Angular2 Pipes, a mechanism for transforming and formatting data within HTML templates in an Angular2 application.