What are pipes in Angular?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Angular basics — a prerequisite for any developer role.
Answer
Pipes transform data for display in templates without modifying the underlying data. They use the | operator in template expressions. Built-in pipes: DatePipe: {{ today | date:"fullDate" }} → "Monday, January 15, 2024"; CurrencyPipe: {{ price | currency:"EUR":"symbol":"1.2-2" }}; DecimalPipe: {{ value | number:"1.1-3" }}; PercentPipe: {{ ratio | percent }}; UpperCasePipe / LowerCasePipe / TitleCasePipe; JsonPipe: {{ obj | json }} — pretty-prints for debugging; AsyncPipe: {{ observable$ | async }} — subscribes to Observable or Promise, returns latest value, auto-unsubscribes on component destroy; SlicePipe: {{ array | slice:0:5 }}; KeyValuePipe: iterate over object properties in *ngFor. Chaining pipes: {{ name | uppercase | slice:0:5 }}. Pipe parameters: {{ date | date:"shortDate":"UTC" }} — colon-separated args. Custom pipes: ng g pipe truncate — implement PipeTransform interface with transform(value: string, limit: number): string. Pure vs impure pipes: pure (default) — only called when input reference changes (efficient); impure — called on every change detection cycle (use sparingly — can be slow). AsyncPipe is impure. Standalone pipe: add standalone: true to the pipe decorator.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Angular answers easy to follow.