Thuta Learning
Angular
IntermediateWeb DevelopmentIntermediate

Built-in Pipes

AngularLesson 2520 min

What you'll walk away with

  • Explain the core concept and Angular data flow of Built-in Pipes
  • Run the example, predict its state and UI, and test edge and error cases
  • Apply a typed safe pattern in a real project and recognize common pitfalls

Explain it simply

Built-in Pipes, in plain language

Pipes are used to transform/format data inside a template. Angular ships with a bunch of built-in pipes.

Problem → Why → Solution

The problem — why this concept matters

Formatting a server UTC timestamp without a deliberate timezone can display the wrong calendar day.

A common mistake

One happy-path result does not prove the feature works; empty, loading, error, and cleanup behavior need explicit tests.

Core concept — understand how it works

Pipes transform values for display without changing source data. Date, currency, and number pipes require explicit locale, timezone, and formatting policy for correct user-facing output. Pure pipes rerun when input references change, so mutable collections should use immutable updates.

Mental model
  1. input and state
  2. component and template
  3. rendered Angular UI

Explain the core concept and Angular data flow of Built-in Pipes

Core syntax or pattern

typescript
<!-- String pipes -->
<p>{{ 'hello world' | uppercase }}</p>        <!-- HELLO WORLD -->
<p>{{ 'HELLO WORLD' | lowercase }}</p>        <!-- hello world -->
<p>{{ 'hello world' | titlecase }}</p>        <!-- Hello World -->

<!-- Number pipes -->
<p>{{ 1234.5678 | number:'1.2-2' }}</p>      <!-- 1,234.57 -->
<p>{{ 0.25 | percent }}</p>                   <!-- 25% -->
<p>{{ 99.99 | currency:'USD' }}</p>           <!-- $99.99 -->

<!-- Date pipe -->
<p>{{ today | date:'short' }}</p>             <!-- 10/16/25, 3:45 PM -->
<p>{{ today | date:'fullDate' }}</p>          <!-- Thursday, October 16, 2025 -->
<p>{{ today | date:'dd/MM/yyyy' }}</p>        <!-- 16/10/2025 -->

<!-- JSON pipe (for debugging) -->
<pre>{{ user | json }}</pre>

// component.ts
export class MyComponent {
  today = new Date();
  user = { name: 'John', age: 25 };
}

Pipes transform values for display without changing source data. Date, currency, and number pipes require explicit locale, timezone, and formatting policy for correct user-facing output. Pure pipes rerun when input references change, so mutable collections should use immutable updates.

Read the code step by step

  1. input and state<!-- String pipes -->

    Pipes are used to transform/format data inside a template. Angular ships with a bunch of built-in pipes.

  2. component and template<p>{{ today | date:'short' }}</p> <!-- 10...

    Pipes transform values for display without changing source data. Date, currency, and number pipes require explicit locale, timezone, and formatting policy for correct user-facing output. Pure pipes rerun when input references change, so mutable collections should use immutable updates.

  3. rendered Angular UI}

    Format an order summary with date, currency, and percent pipes, then test two locales, a timezone boundary, and null fallback.

Execution flow
  1. input and state
  2. component and template
  3. rendered Angular UI

Success

Explain the core concept and Angular data flow of Built-in Pipes

Failure

Formatting a server UTC timestamp without a deliberate timezone can display the wrong calendar day.

Pipes are used to transform/format data inside a template. Angular ships with a bunch of built-in pipes.

typescript
<!-- String pipes -->
<p>{{ 'hello world' | uppercase }}</p>        <!-- HELLO WORLD -->
<p>{{ 'HELLO WORLD' | lowercase }}</p>        <!-- hello world -->
<p>{{ 'hello world' | titlecase }}</p>        <!-- Hello World -->

<!-- Number pipes -->
<p>{{ 1234.5678 | number:'1.2-2' }}</p>      <!-- 1,234.57 -->
<p>{{ 0.25 | percent }}</p>                   <!-- 25% -->
<p>{{ 99.99 | currency:'USD' }}</p>           <!-- $99.99 -->

<!-- Date pipe -->
<p>{{ today | date:'short' }}</p>             <!-- 10/16/25, 3:45 PM -->
<p>{{ today | date:'fullDate' }}</p>          <!-- Thursday, October 16, 2025 -->
<p>{{ today | date:'dd/MM/yyyy' }}</p>        <!-- 16/10/2025 -->

<!-- JSON pipe (for debugging) -->
<pre>{{ user | json }}</pre>

// component.ts
export class MyComponent {
  today = new Date();
  user = { name: 'John', age: 25 };
}
You should see
(The data gets transformed into the specified formats and displayed)

Real-world usage

How to apply it in a real project

Format an order summary with date, currency, and percent pipes, then test two locales, a timezone boundary, and null fallback.

Mini challenge

Build it yourself

Rebuild the Built-in Pipes example without copying it. Add two normal states, one edge case, and one failure state, and write the expected UI and state transition before running it.

  • Rebuild the example without copying it
  • Test a normal input and an edge case
  • Predict the compiler or output result before running it
typescript
<!-- String pipes -->
<p>{{ 'hello world' | uppercase }}</p>        <!-- HELLO WORLD -->
<p>{{ 'HELLO WORLD' | lowercase }}</p>        <!-- hello world -->
<p>{{ 'hello world' | titlecase }}</p>        <!-- Hello World -->

<!-- Number pipes -->
<p>{{ 1234.5678 | number:'1.2-2' }}</p>      <!-- 1,234.57 -->
<p>{{ 0.25 | percent }}</p>                   <!-- 25% -->
<p>{{ 99.99 | currency:'USD' }}</p>           <!-- $99.99 -->

<!-- Date pipe -->
<p>{{ today | date:'short' }}</p>             <!-- 10/16/25, 3:45 PM -->
<p>{{ today | date:'fullDate' }}</p>          <!-- Thursday, October 16, 2025 -->
<p>{{ today | date:'dd/MM/yyyy' }}</p>        <!-- 16/10/2025 -->

<!-- JSON pipe (for debugging) -->
<pre>{{ user | json }}</pre>

// component.ts
export class MyComponent {
  today = new Date();
  user = { name: 'John', age: 25 };
}

Expected: Explain the core concept and Angular data flow of Built-in Pipes

Show hint

Format an order summary with date, currency, and percent pipes, then test two locales, a timezone boundary, and null fallback.

Quick quiz 1 / 3

What best describes the core idea of Built-in Pipes?

Quick quiz 2 / 3

Which mistake should you avoid first?

Quick quiz 3 / 3

How should this be applied in a real project?

What to remember

  • input and state → component and template → rendered Angular UI
  • Pipes transform values for display without changing source data. Date, currency, and number pipes require explicit locale, timezone, and formatting policy for correct user-facing output. Pure pipes rerun when input references change, so mutable collections should use immutable updates.
  • Formatting a server UTC timestamp without a deliberate timezone can display the wrong calendar day.
  • Format an order summary with date, currency, and percent pipes, then test two locales, a timezone boundary, and null fallback.

Angular — Templates — Angular

Easy traps

  • Formatting a server UTC timestamp without a deliberate timezone can display the wrong calendar day.
  • One happy-path result does not prove the feature works; empty, loading, error, and cleanup behavior need explicit tests.

Hands-on Exercise

Rebuild the Built-in Pipes example without copying it. Add two normal states, one edge case, and one failure state, and write the expected UI and state transition before running it.

You'll know it worked when: (The data gets transformed into the specified formats and displayed)

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Built-in Pipes | Thuta Learning