How to create and use a custom pipes?



How to create and use a custom pipes?..

Answer / Sindu Chauhan

To create a custom pipe in Angular 2, you can follow these steps:
1. Import the PipeTransform interface from @angular/core.
2. Create a new class that extends the PipeTransform interface.
3. Define transform() method to transform the input value.
4. Register your custom pipe in app.module.ts by adding it to the array of declarations.
5. Use the pipe in your template by calling it with the pipe name as a suffix on the curly braces.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

Is node js faster than java?

1 Answers  


Explain filter filter?

1 Answers  


What's new in angular 6? What are improvements in angular 6?

1 Answers  


What do you mean by templateref and viewcontainerref?

1 Answers  


Explain the role of $routeprovider in angularjs?

1 Answers  


What is angular cli command?

1 Answers  


On which types of the component can we create a custom directive?

1 Answers  


What are angular 2 directive?

1 Answers  


What are the possible ways to bind component properties to an associated template?

1 Answers  


What is restrict option in directive?

1 Answers   Xoriant,


How to updating angular cli?

1 Answers  


Explain $event in angular 5?

1 Answers  


Categories