Thuta Learning
Angular
IntermediateWeb Developmentအလယ်အလတ်

Built-in Pipes

Angularသင်ခန်းစာ 2520 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Built-in Pipes ရဲ့ core concept နဲ့ Angular data flow ကိုရှင်းပြနိုင်ရန်
  • နမူနာ UI ကို run၊ state/output ခန့်မှန်းပြီး edge/error cases စမ်းနိုင်ရန်
  • လက်တွေ့ project တွင် typed safe pattern နဲ့ common pitfalls ကိုခွဲသိနိုင်ရန်

ရိုးရိုးလေး ရှင်းပြမယ်

Built-in Pipes ကို ရိုးရိုးလေးနားလည်မယ်

Pipes များသည် template ထဲတွင် data များကို transform/format လုပ်ရန် အသုံးပြုသည်။ Angular တွင် built-in pipes များစွာ ပါဝင်သည်။

Problem → Why → Solution

ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ

Date pipe ကို timezone မသတ်မှတ်ဘဲ server UTC value နဲ့သုံးလျှင် user ရက်စွဲတစ်ရက်လွဲနိုင်ပါတယ်။

ဖြစ်လေ့ရှိတဲ့အမှား

Happy path တစ်ခုအောင်တာနဲ့ feature မှန်ပြီဟုယူဆခြင်းက empty, loading, error နဲ့ cleanup bugs များကိုလွတ်စေနိုင်ပါတယ်။

Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်

Pipes က template display transformation အတွက်ဖြစ်ပြီး underlying data ကိုမပြောင်းသင့်ပါ။ Date, currency, decimal စတဲ့ pipes တွင် locale, timezone နဲ့ format policy ကိုexplicit ထားမှ user-facing output မှန်ပါတယ်။ Pure pipes က input reference မပြောင်းလျှင်ပြန်မတွက်တာကြောင့် mutable collections နဲ့သုံးရာမှာ immutable update လိုပါတယ်။

Mental Model
  1. Input + state
  2. Component + template
  3. Rendered Angular UI

Built-in Pipes ရဲ့ core concept နဲ့ Angular data flow ကိုရှင်းပြနိုင်ရန်

အဓိက Syntax / 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 က template display transformation အတွက်ဖြစ်ပြီး underlying data ကိုမပြောင်းသင့်ပါ။ Date, currency, decimal စတဲ့ pipes တွင် locale, timezone နဲ့ format policy ကိုexplicit ထားမှ user-facing output မှန်ပါတယ်။ Pure pipes က input reference မပြောင်းလျှင်ပြန်မတွက်တာကြောင့် mutable collections နဲ့သုံးရာမှာ immutable update လိုပါတယ်။

Code ကို အဆင့်လိုက်ဖတ်မယ်

  1. Input + state<!-- String pipes -->

    Pipes များသည် template ထဲတွင် data များကို transform/format လုပ်ရန် အသုံးပြုသည်။ Angular တွင် built-in pipes များစွာ ပါဝင်သည်။

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

    Pipes က template display transformation အတွက်ဖြစ်ပြီး underlying data ကိုမပြောင်းသင့်ပါ။ Date, currency, decimal စတဲ့ pipes တွင် locale, timezone နဲ့ format policy ကိုexplicit ထားမှ user-facing output မှန်ပါတယ်။ Pure pipes က input reference မပြောင်းလျှင်ပြန်မတွက်တာကြောင့် mutable collections နဲ့သုံးရာမှာ immutable update လိုပါတယ်။

  3. Rendered Angular UI}

    Order summary မှာ date/currency/percent pipes သုံးပြီး locale နှစ်မျိုး, timezone boundary နဲ့ null fallback ကိုစမ်းပါ။

Execution Flow
  1. Input + state
  2. Component + template
  3. Rendered Angular UI

Success

Built-in Pipes ရဲ့ core concept နဲ့ Angular data flow ကိုရှင်းပြနိုင်ရန်

Failure

Date pipe ကို timezone မသတ်မှတ်ဘဲ server UTC value နဲ့သုံးလျှင် user ရက်စွဲတစ်ရက်လွဲနိုင်ပါတယ်။

Pipes များသည် template ထဲတွင် data များကို transform/format လုပ်ရန် အသုံးပြုသည်။ Angular တွင် 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
(Data များသည် specified formats များအတိုင်း transform ဖြစ်ပြီး ပြသမည်)

Real-world usage

လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ

Order summary မှာ date/currency/percent pipes သုံးပြီး locale နှစ်မျိုး, timezone boundary နဲ့ null fallback ကိုစမ်းပါ။

Mini challenge

ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ

Built-in Pipes နမူနာကို copy မလုပ်ဘဲ ကိုယ်တိုင်ပြန်ရေးပါ။ Normal state နှစ်ခု၊ edge case တစ်ခုနှင့် failure state တစ်ခုထည့်ပြီး expected UI နဲ့ state transition ကိုမ run မီရေးထားပါ။

  • Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
  • Normal input နဲ့ edge case စမ်းပါ
  • Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
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 };
}

ရလဒ်: Built-in Pipes ရဲ့ core concept နဲ့ Angular data flow ကိုရှင်းပြနိုင်ရန်

အရိပ်အမြွက် ကြည့်ရန်

Order summary မှာ date/currency/percent pipes သုံးပြီး locale နှစ်မျိုး, timezone boundary နဲ့ null fallback ကိုစမ်းပါ။

Quick Quiz 1 / 3

Built-in Pipes ရဲ့ အဓိကသဘောတရားက ဘာလဲ။

Quick Quiz 2 / 3

ဘယ်အမှားကို အရင်ဆုံးရှောင်သင့်လဲ။

Quick Quiz 3 / 3

Real project မှာ ဘယ်လိုအသုံးချသင့်လဲ။

ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ

  • Input + state → Component + template → Rendered Angular UI
  • Pipes က template display transformation အတွက်ဖြစ်ပြီး underlying data ကိုမပြောင်းသင့်ပါ။ Date, currency, decimal စတဲ့ pipes တွင် locale, timezone နဲ့ format policy ကိုexplicit ထားမှ user-facing output မှန်ပါတယ်။ Pure pipes က input reference မပြောင်းလျှင်ပြန်မတွက်တာကြောင့် mutable collections နဲ့သုံးရာမှာ immutable update လိုပါတယ်။
  • Date pipe ကို timezone မသတ်မှတ်ဘဲ server UTC value နဲ့သုံးလျှင် user ရက်စွဲတစ်ရက်လွဲနိုင်ပါတယ်။
  • Order summary မှာ date/currency/percent pipes သုံးပြီး locale နှစ်မျိုး, timezone boundary နဲ့ null fallback ကိုစမ်းပါ။

Angular — Templates — Angular

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Date pipe ကို timezone မသတ်မှတ်ဘဲ server UTC value နဲ့သုံးလျှင် user ရက်စွဲတစ်ရက်လွဲနိုင်ပါတယ်။
  • Happy path တစ်ခုအောင်တာနဲ့ feature မှန်ပြီဟုယူဆခြင်းက empty, loading, error နဲ့ cleanup bugs များကိုလွတ်စေနိုင်ပါတယ်။

လက်တွေ့လေ့ကျင့်ခန်း

Built-in Pipes နမူနာကို copy မလုပ်ဘဲ ကိုယ်တိုင်ပြန်ရေးပါ။ Normal state နှစ်ခု၊ edge case တစ်ခုနှင့် failure state တစ်ခုထည့်ပြီး expected UI နဲ့ state transition ကိုမ run မီရေးထားပါ။

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: (Data များသည် specified formats များအတိုင်း transform ဖြစ်ပြီး ပြသမည်)

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Built-in Pipes | Thuta Learning