Loading

Quipoin Menu

Learn • Practice • Grow

angular / Pipes
interview

Q1. What are pipes in Angular?
Pipes are simple functions that transform data in templates. They take input and return formatted output. Angular provides built-in pipes like date, uppercase, currency, json, and async. Pipes are used with the pipe symbol (|). Example:
{{ price | currency:''USD'' }}

Q2. What are some commonly used built-in pipes?
Common pipes: date (format dates), uppercase/lowercase (change case), currency (format as currency), percent (format as percentage), decimal (number formatting), json (convert to JSON string), async (unwrap observable/promise), slice (take array slice). Each pipe can take parameters for customization.

Q3. What is the async pipe and why use it?
The async pipe subscribes to an observable or promise and returns the latest emitted value. It automatically handles unsubscription to prevent memory leaks. Example:
{{ data$ | async }}
It''s essential for reactive programming.

Q4. Can you chain multiple pipes?
Yes, pipes can be chained. The output of one pipe becomes the input of the next. Order matters. Example:
{{ name | uppercase | slice:0:3 }}
This first converts to uppercase, then takes first 3 characters.

Q5. What are pure and impure pipes?
Pure pipes are stateless and only called when their input changes (by reference). Most built-in pipes are pure. Impure pipes are called on every change detection cycle, which can impact performance. Custom pipes are pure by default; you set pure: false to make them impure.