Angular တွင် Component ၏ Class Properties များကို Template ထဲတွင် အသုံးပြုခြင်း

Component class ၏ public properties အားလုံးသည် Component ၏ template အတွင်းမှ အသုံးပြုနိုင်မည် ဖြစ်သည်။ ၎င်းတို့ကို မည်သို့ခေါ်ယူအသုံးပြုရမည်ကို ကြည့်ရအောင်။

ကျွန်ုပ်တို့၏ class ထဲတွင် အောက်ပါ public property ရှိသည်ဆိုပါစို့။

app/app.component.tsexport class AppComponent {
  public test: string = 'abcde';
}

ကျွန်ုပ်တို့၏ property အတွင်းရှိ အကြောင်းအရာကို ထုတ်ပြရန် ဖြစ်သည်။ ၎င်းကို ပြုလုပ်ရန် curly braces နှစ်ထပ်အတွင်း၌ property ၏ အမည်ကို ရေးရပါမည်။

app/app.component.html<div>
  {{ test }}
</div>
Задание 1

အောက်ပါ template ကို ပေးထားပါသည်။

app/app.component.html<ul>
  <li>name: john</li>
  <li>surn: smit</li>
</ul>

အမည်နှင့် မိသားစုအမည်များကို component class မှ template ထဲသို့ ပို့ဆောင်အောင်ပြုလုပ်ပါ။