Manipulating data with pipes
The syntax of a pipe is pretty simple, consisting of the pipe name following the expression we want to transform, separated by a pipe symbol (
|). Pipes are usually used with interpolation in Angular templates and can be chained to each other. Angular has a wide range of pipe types already baked into it.
Before moving on to explore some of the built-in Angular pipes, we will make a change to our Angular working application to demonstrate their use better. The
products array in the product list component is currently an array of string values. We will convert it into an array of product objects using interfaces:
- Run the following Angular CLI command inside the
src\app\productsfolder to create a
ng generate interface product...