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.
Function/Parameter | Explanation |
---|---|
@Pipe({name, pure}) | metadata for pipe, must immediately precede pipe class |
name: string | what you will use inside the template |
pure: boolean | defaults 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: any | the 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?) |
This topic covers Angular2 Pipes, a mechanism for transforming and formatting data within HTML templates in an Angular2 application.