Angular တွင် Template အတွင်း Component Class Method များကို ခေါ်ယူခြင်း
HTML markup အတွင်းမှလည်း class ၏ public method များကို ခေါ်ယူနိုင်ပါသည်။ လက်တွေ့စမ်းကြည့်ကြရအောင်။ ကျွန်ုပ်တို့တွင် အောက်ပါ method ရှိသည်ဟု ယူဆပါစို့။
export class AppComponent {
public show() {
return 'abcde';
}
}
၎င်းကို markup အတွင်းတွင် ခေါ်ယူကြည့်ပါ။
<div>
{{ show() }}
</div>
Component class အတွင်းတွင် အောက်ပါ method များရှိသည်ဟု ယူဆပါ။
export class AppComponent {
public showName() {
return 'john';
}
public showSurn() {
return 'smit';
}
}
Component ၏ template file အတွင်းတွင် နာမည်နှင့် မျိုးနွယ်အမည်ကို ထုတ်ပြပါ။