AppML ထိန်းချုပ် ကိရိယာများ
AppML controller ၏ ရည်ရွယ်ချက်မှာ သင့်အပလီကေးရှင်း ကို ထိန်းချုပ်နိုင် စေရန် ဖြစ်သည်။
Controller က ဘာလုပ်နိုင်သလဲ
- ကနဦးဒေတာကို သတ်မှတ်ပါ။
- လျှောက်လွှာဒေတာကို ပြောင်းပါ။
- အဝင်နှင့်အထွက်ကိုကိုင်တွယ်ပါ။
- အချက်အလက်ကို အတည်ပြုပါ။
- အချက်အလက်အကျဉ်းချုပ်
- အမှားများကို ကိုင်တွယ်ပါ။
- အပလီကေးရှင်းများကို စတင်ပြီး ရပ်လိုက်ပါ။
- ပြီးတော့နောက်ထပ်အများကြီးပဲ
Controller မပါဘဲ
မူရင်း AppML အပလီကေးရှင်းများသည် ထိန်းချုပ်ကိရိယာမပါဘဲ လုပ်ဆောင်သည်-
ဥပမာ
<table appml-data="customers.js">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</td>
</tr>
</table>
Controller တစ်ခုနှင့်
AppML ထိန်းချုပ်ကိရိယာဖြင့်၊ သင်သည် သင့်လျှောက်လွှာကို JavaScript ဖြင့် ထိန်းချုပ် နိုင်သည် ။
ထိန်းချုပ်ကိရိယာသည် သင်ပံ့ပိုးပေး သည့် JavaScript လုပ်ဆောင်ချက် ဖြစ်သည်။
controller function ကိုရည်ညွှန်းရန် appml-controller attribute ကိုအသုံးပြု သည် ။
ဥပမာ
<h1>Customers</h1>
<table appml-data="customers.js" appml-controller="myController">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</td>
</tr>
</table>
<script>
function myController($appml) {
if ($appml.message == "display") {
if ($appml.display.name == "CustomerName")
{
$appml.display.value = $appml.display.value.toUpperCase();
}
}
}
</script>
အထက်ဖော်ပြပါ ဥပမာရှိ ထိန်းချုပ်ကိရိယာ (myController) သည် ၎င်းကိုမပြသမီတွင် "CustomerName" ၏တန်ဖိုးကို စာလုံးကြီးအဖြစ် ပြောင်းလဲသည်။
သင့်တွင် ထိန်းချုပ်ကိရိယာတစ်ခုရှိပါက၊ AppML သည် အရေးကြီးသောလုပ်ဆောင်ချက်တိုင်းအတွက် ထိန်းချုပ်သူ ထံသို့ အပလီကေးရှင်းအရာဝတ္ထု ($appml) ကို ပေးပို့မည်ဖြစ်သည်။
အပလီကေးရှင်း၏ ဂုဏ်သတ္တိများထဲမှ တစ်ခုသည် အပလီကေးရှင်းအခြေအနေအား ဖော်ပြသည့် မက်ဆေ့ဂျ် ($appml.message) ဖြစ်သည်။
Message | Description |
---|---|
ready | Sent after AppML is initiated, and ready to load data. |
loaded | Sent after AppML is fully loaded, ready to display data. |
display | Sent before AppML displays a data item. |
done | Sent after AppML is done (finished displaying). |
submit | Sent before AppML submits data. |
error | Sent after AppML has encountered an error. |
မက်ဆေ့ချ်များကို နောက်အခန်းတွင် ရှင်းပြထားသည်။