Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Angular Templates: Pipes in Templates (|)


Format and transform values inline using the | operator.


What are Pipes in Templates (|)?

  • Transform values for display using the | operator.
  • Accept optional arguments (e.g., formats, locales).
  • Multiple pipes can be chained.

When to use Pipes

  • Format dates, numbers, and text directly in the template.
  • Use pure pipes for performance.
  • Move complex or side-effectful logic to the component.
{{ amount | currency:'USD' }}

{{ amount | currency:'USD' }}: Formats amount as US dollars using the built-in CurrencyPipe.


Example

Transform values using pipes:

Example

import { bootstrapApplication } from '@angular/platform-browser';
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule],
  template: `
    <h3>Built-in pipes</h3>
    <p>Today: {{ today | date:'yyyy-MM-dd' }}</p>
    <p>Name: {{ name | uppercase }}</p>
    <p>Chained: {{ ratio | percent:'1.0-2' | uppercase }}</p>
  `
})
export class App {
  today = new Date();
  name = 'Ada Lovelace';
  ratio = 0.756;
}

bootstrapApplication(App);
<app-root></app-root>

Run Example »

Example explained

  • date:'yyyy-MM-dd': Formats the today Date using the provided format string (year-month-day). Locale defaults apply unless specified.
  • uppercase: Transforms the string value of name to upper case.
  • percent:'1.0-2': Formats ratio as a percentage with digitsInfo (minInteger.minFraction-maxFraction): 1 integer digit, 0–2 fraction digits.
  • Chaining: Pipes run left to right. ratio | percent:'1.0-2' | uppercase first formats a percent string, then uppercases it.

See Pipes for a full tour and custom pipes.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.