我正试图摆脱这个空的<选项>在我的< select>中。我已经阅读了其他一些关于此的问题,但它们似乎都没有帮助我。任何人都可以帮我摆脱空的<选项>在这个小提琴?感谢。
JS
function testCtrl($scope) {
$scope.data = {};
$scope.data.club = {'1':{name:'club name!'}};
$scope.data.admin = [{related_id:'1',related_table:'club'}]
//$scope.admin_idx = 0;
}
HTML
<div ng-controller="testCtrl">
<select ng-model="admin_idx">
<option ng-repeat="admin in data.admin" value="{{$index}}">
{{data[admin.related_table][admin.related_id].name}}</option>
</select>
答案 0 :(得分:3)
http://docs.angularjs.org/api/ng.directive:select
<select ng-model="admin_idx"
ng-options="$index as data[admin.related_table][admin.related_id].name for admin in data.admin">
</select>
希望这会有所帮助