Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Expert Angular

You're reading from   Expert Angular Build deep understanding of Angular to set you apart from the developer crowd

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher Packt
ISBN-13 9781785880230
Length 454 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (4):
Arrow left icon
Sridhar Rao Chivukula Sridhar Rao Chivukula
Author Profile Icon Sridhar Rao Chivukula
Sridhar Rao Chivukula
Mathieu Nayrolles Mathieu Nayrolles
Author Profile Icon Mathieu Nayrolles
Mathieu Nayrolles
Alexandru Vasile Pop Alexandru Vasile Pop
Author Profile Icon Alexandru Vasile Pop
Alexandru Vasile Pop
Rajesh Gunasundaram Rajesh Gunasundaram
Author Profile Icon Rajesh Gunasundaram
Rajesh Gunasundaram
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Architectural Overview and Building a Simple App in Angular 2. Migrating AngularJS App to Angular App FREE CHAPTER 3. Using Angular CLI to Generate Angular Apps with Best Practices 4. Working with Components 5. Implementing Angular Routing and Navigation 6. Creating Directives and Implementing Change Detection 7. Asynchronous Programming Using Observables 8. Template and Data Binding Syntax 9. Advanced Forms in Angular 10. Material Design in Angular 11. Implementing Angular Pipes 12. Implementing Angular Services 13. Applying Dependency Injection 14. Handling Angular Animation 15. Integrating Bootstrap with Angular Application 16. Testing Angular Apps Using Jasmine and Protractor Frameworks 17. Design Patterns in Angular

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime