How it works...

You can use an Angular pipe in the view to simply convert or transform any value to a desired value. There are no limitations to how you structure the pipe. Angular automatically detects the | sign in the template and turns the value in front of it to an input. To create a pipe, you must import the decorator and provide a name (see custom-pipe.ts), as shown:

import { Pipe, PipeTransform } from '@angular/core'; 
 
@Pipe({name: 'userExtract'}) 

The input from the template is the following value parameter:

transform(value: any, arg) : any { 

The value returned by the transform method will be the output to the view, as shown in the following code:

return newVal; 

In this example, you are taking a parameter for the pipe to process, ...

Get Ionic Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.