Introduction to Pipes and Creating Interfaces

Learn about the purpose of pipes and how to create interfaces in Angular.

Pipes allow us to transform the outcome of our expressions at the view level. They take data as input, transform it into the desired format, and display the output in the template.

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 built 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 better demonstrate their use. 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.

Using interface in our Angular Application

  1. Run the following Angular CLI command inside the src\app\products folder to create a product interface:

Note: The command below is for creating the interface on the local machine using the Angular CLI.

Get hands-on with 1400+ tech skills courses.