AngularJS 下拉框

AngularJS 允许您基于数组或对象中的项目创建下拉列表。

使用 ng-options 创建下拉框

如果您想在 AngularJS 中基于对象或数组创建下拉列表,应该使用 ng-options အမိန့်:

အမှတ်အသား

</select>

ကိုယ်တိုင် ကြိုးစားပါ

由于 ng-repeat 指令为数组中的每个项目重复一段 HTML 代码,因此它可用于在下拉列表中创建选项,但是 ng-options အမိန့် သည် နှီးနှောက် စာရင်း တွင် ဖြည့်စွက် ရန် ဖြည့်စွက် ရေး အတွက် ဖြည့်စွက် ပြီးခဲ့သည့် အမိန့် ဖြစ်ပါသည်。

သို့မဟုတ် အမိန့် မှာ ဘယ်အမိန့် ကို အသုံးပြုရမည်လား?

သင် အသုံးပြုနိုင်သည် ng-repeat အမိန့် နှင့် ng-options အမိန့်:

假设您有一个对象数组:

$scope.cars = [
  {model : "Ford Mustang", color : "red"},
  {model : "Fiat 500", color : "white"},
  {model : "Volvo XC90", color : "black"}
];

အမှတ်အသား

使用 ng-repeat


  
</select>

You selected a {{selectedCar.color}} {{selectedCar.model}}

ကိုယ်တိုင် ကြိုးစားပါ

အမှတ်အသား

使用 ng-options