Reader small image

You're reading from  Expert Angular

Product typeBook
Published inJul 2017
Reading LevelExpert
PublisherPackt
ISBN-139781785880230
Edition1st Edition
Languages
Right arrow
Author (1)
Sridhar Rao Chivukula
Sridhar Rao Chivukula
author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula

Right arrow

Creating custom pipes

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:

  1. Create a template to apply it to the pipe ( in our example, it's updateTaxPipe).
  2. Create a pipe file, that is, update-tax.pipe.ts.
    1. Every pipe file will have to import the pipe from the Angular core.
    2. Define the pipe metadata.
    3. Create the Component class...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Expert Angular
Published in: Jul 2017Publisher: PacktISBN-13: 9781785880230

Author (1)

author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula