ရိုးရိုးလေး ရှင်းပြမယ်
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 လိုပါတယ်။
- Input + state
- Component + template
- Rendered Angular UI
Built-in Pipes ရဲ့ core concept နဲ့ Angular data flow ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
<!-- 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 ကို အဆင့်လိုက်ဖတ်မယ်
- Input + state
<!-- String pipes -->Pipes များသည် template ထဲတွင် data များကို transform/format လုပ်ရန် အသုံးပြုသည်။ Angular တွင် built-in pipes များစွာ ပါဝင်သည်။
- 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 လိုပါတယ်။
- Rendered Angular UI
}Order summary မှာ date/currency/percent pipes သုံးပြီး locale နှစ်မျိုး, timezone boundary နဲ့ null fallback ကိုစမ်းပါ။
- Input + state
- Component + template
- 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 များစွာ ပါဝင်သည်။
<!-- 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 };
}(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 ကိုခန့်မှန်းပါ
<!-- 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
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- 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