Thuta Learning
ရှာဖွေရန်
BasicWeb Developmentintermediate

Templates & Interpolation

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Component ၏ UI ကို HTML ဖြင့်ရေးသားသည်။ Interpolation {{...}} ကို အသုံးပြုပြီး TypeScript class မှ data များကို template ထဲတွင် ပြသနိုင်သည်။

typescript
<div>
  <h2>User Profile</h2>
  <p>Username: {{ username }}</p>
  <p>Account Age: {{ getAccountAge() }} years</p>
</div>

// user-profile.component.ts
export class UserProfileComponent {
  username = 'Jane Doe';
  getAccountAge() {
    return 2;
  }
}
You should see
(Browser တွင် 'Username: Jane Doe' နှင့် 'Account Age: 2 years' ဟု ပေါ်လာမည်)
Templates & Interpolation | Thuta Learning