我的范围内有这个数组
$scope.containers = [{id: 1, title: "Icebox"}, {id: 2, title: "Summer"},
{id: 3, title: "Milestone"}];
我可以创建像ng-options这样的东西吗?
<option value="1">Icebox</option>
<option value="2">Summer</option>
<option value="3">Milestone</option>
是的,如果您有兴趣以这种方式显示标题:
<select>
<option
ng-repeat="v in containers"
value="{{v.id}}"
title="{{v.title}}"
ng-selected="adresses.indexOf(v) == 0">{{v.title}}
</option>
</select>
但是z zxswい
但如果你只想展示qazxsw poi qazxsw poi就足够了
我遇到了同样的问题,我被要求使用ng-options,这是我的解决方案......
HTML:
ng-options
控制器:
<select ng-options="v.id as v.title for v in containers" ng-model="selectedId">
</select>
请参阅此指令,了解有关ng-options的选项的标题。
Fiddle DEMO
像这样使用它
<select ng-options="item.Id as item.Name for item in vm.listOfItems">
<option disabled>Select a value</option>
</select>
希望能帮助到你