如何使用ng-options显示值

时间:2015-05-27 00:30:48

标签: json angularjs

我的目标是

$scope.Data = { "lineList" : [
    "apple",
    "banana",
    "orange"]
}

如何在ng =选项中显示这些元素。以下没有工作。

<select ng-model="selecteditem" ng-options="selectedLine as selectedLine.lineList for selectedLine in Data">
</select>

1 个答案:

答案 0 :(得分:0)

假设您正试图展示&#34; Apple&#34;,&#34; Orange&#34;,&#34; Banana&#34; ......您只需要这样做。

您的currtent数据模型

$scope.Data = { "lineList" : [
"apple",
"banana",
"orange"]

}

修复

<select ng-model="selecteditem" ng-options="selectedLine as selectedLine for selectedLine in Data['lineList']">