如何在AngularJS中显示“选择中的关键点”下拉列表

如何在AngularJS中显示“选择中的关键点”下拉列表,angularjs,select,Angularjs,Select,我的JSON是: { "_id" : ObjectId("54c2523d581c4c8c218d2392"), "aboutUs" : "Demo About Us." } { "_id" : ObjectId("54c2523d581c4c8c218d2393"), "tutorial" : "Demo Tutorial." } 我想在下拉列表中显示aboutUs和tutorial,并在更改select下拉列表时获得相应的值 例如,如果我们选择abou

我的JSON是:

{
    "_id" : ObjectId("54c2523d581c4c8c218d2392"),
    "aboutUs" : "Demo About Us." 
}

{
    "_id" : ObjectId("54c2523d581c4c8c218d2393"),
    "tutorial" : "Demo Tutorial." 
}
我想在下拉列表中显示aboutUs和tutorial,并在更改select下拉列表时获得相应的值


例如,如果我们选择aboutUs,那么我们会得到关于我们的演示。

如果这是您仅有的两个选项,那么您应该对它们进行硬编码,因为每个关键点对于每个对象都是唯一的

<select ng-model="selectedOption">
  <option value="aboutUs">Demo About Us<option>
  <option value="tutorial">Demo Tutorial<option>
</select>
然后,您可以创建类似的:

$scope.selectOptions = [
   { 
      id: 123,
      key: "aboutUs",
      value: "Demo About Us",
   },
   { 
      id: 456,
      key: "tutorial",
      value: "Demo Tutorial",
   },
   // etc...
];
<div ng-model="selectedOption"
     ng-option="o.key as o.value for o in selectOptions">
</div>