So far, so good. Pipes have really impressed us, but wait, there's more awesome things we can do with pipes. Built-in pipes, as you see, are very limited and few. We certainly need to create our own custom pipes, which cater to our app's functionality.
In this section, you will learn how to create a custom pipe for our application.
In this example, we will build a pipe, which will be a tax calculator. We pass the price of the product and use a pipe functionality to automatically calculate and display the sales tax. Magic, right?
To create a custom pipe, we need to perform the following steps:
- Create a template to apply it to the pipe ( in our example, it's updateTaxPipe).
- Create a pipe file, that is, update-tax.pipe.ts.
- Every pipe file will have to import the pipe from the Angular core.
- Define the pipe metadata.
- Create the Component class...