Angular တွင် Component Class မှ Properties များကို Attribute များအဖြစ် အသုံးပြုခြင်း
Class ၏ public properties များကို tag များ၏ text အဖြစ်သာမက attribute တန်ဖိုးများအဖြစ်လည်း ထုတ်ပြနိုင်ပါသည်။ လက်တွေ့စမ်းကြည့်ကြရအောင်။ ကျွန်ုပ်တို့၏ class တွင် အောက်ပါ property ရှိသည်ဆိုပါစို့:
export class AppComponent {
public test: string = 'abcde';
}
ကျွန်ုပ်တို့၏ property ၏ ပါဝင်မှုကို tag ၏ attribute တွင် ထုတ်ပြကြပါစို့:
<div id="{{ test }}">
text
</div>
အောက်ပါ markup ကို ပေးထားပါသည်:
<img src="test.png" alt="picture">
Attribute များ၏ ပါဝင်မှုကို component class မှ ရယူပြီး ပေးပို့နိုင်အောင် ပြင်ဆင်ပါ။