AngularJS ng-options
ညွှန်ကြားချက်
ဥပမာ
array တစ်ခု၏အရာများကိုအသုံးပြုခြင်းဖြင့် dropdown list တွင်ရွေးချယ်စရာများကိုဖြည့်ပါ-
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedName"
ng-options="item for item in names"></select>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl',
function($scope) {
$scope.names = ["Emil", "Tobias",
"Linus"];
});
</script>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ညွှန်ကြားချက် သည် ng-options
<select> ဒြပ်စင်တစ်ခုကို <options> ဖြင့် ဖြည့်ပေးသည်။
ng-options
ညွှန်ကြားချက်သည် dropdown list ကိုဖြည့်ရန် array ကိုအသုံးပြုသည် ။ အခြေအနေ များစွာတွင် ညွှန်ကြားချက်ကို အသုံးပြုရန် ပိုမိုလွယ်ကူ ng-repeat
သော်လည်း ညွှန်ကြားချက်ကို အသုံးပြုသည့်အခါတွင် သင်သည် ပိုမိုပြောင်းလွယ်ပြင်လွယ်ရှိသည် ng-options
။
အထားအသို
<select ng-options="array expression"></select>
<select> ဒြပ်စင်မှပံ့ပိုးထားသည်။
ကန့်သတ်တန်ဖိုးများ
Value | Description |
---|---|
array expression | An expression that selects the specified parts of an array to fill the
select element. Legal expressions: label for value in array select as label for value in array label group by group for value in array label disable when disable for value in array label group by group for value in array track by expression label disable when disable for value in array track by expression label for value in array | orderBy expression track by expression |