问问题
6356 次
3 回答
10
由于您可以控制模型,因此文档在此处有一个示例。
将您的模型转换为如下所示:
var animals = [
{name: "great dane", subcat: "Dogs"},
{name: "lab", subcat: "Dogs"},
{name: "tabby", subcat: "Cats"},
{name: "black", subcat: "Cats"}
];
// and put it in the $scope
$scope.animals = animals;
选择看起来像:
<select ng-model="..." ng-options="a.name group by a.subcat for a in animals">
选择将是具有name
和subcat
属性的整个动物对象。
于 2013-09-10T21:03:52.670 回答
1
无需展平数据的替代方法是使用嵌套ng-repeat
指令,如本文所述。
于 2014-07-30T16:45:45.093 回答
0
<div ng-repeat="people in People">
<label>{{people.firstName}}</label>
<select>
<option ng-repeat-start="choice in people.Choices" ng-bind="choice.Name"></option>
<option ng-repeat-end ng-repeat="opt in choice.Options" ng-bind="' - ' + opt.Name"></option>
</select>
</div>
于 2016-03-14T21:20:13.943 回答