Angular တွင် Component Class မှ Properties များကို Attribute များအဖြစ် အသုံးပြုခြင်း

Class ၏ public properties များကို tag များ၏ text အဖြစ်သာမက attribute တန်ဖိုးများအဖြစ်လည်း ထုတ်ပြနိုင်ပါသည်။ လက်တွေ့စမ်းကြည့်ကြရအောင်။ ကျွန်ုပ်တို့၏ class တွင် အောက်ပါ property ရှိသည်ဆိုပါစို့:

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

ကျွန်ုပ်တို့၏ property ၏ ပါဝင်မှုကို tag ၏ attribute တွင် ထုတ်ပြကြပါစို့:

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

အောက်ပါ markup ကို ပေးထားပါသည်:

app/app.component.html<img src="test.png" alt="picture">

Attribute များ၏ ပါဝင်မှုကို component class မှ ရယူပြီး ပေးပို့နိုင်အောင် ပြင်ဆင်ပါ။