我有6个列表,我通过脚本填充。 我使用角度js,我的HTML看起来像这样:
C.objects.all().select_related('z').prefetch_related('z__b_set')
脚本:
<div class="advancedSearch hidden">
<div class="col-md-4 col-xs-12">
<select name="number" ng-model="Numbers" ng-change="listSearchChnage(Numbers, 'number')" class="form-control" >
<option value="">Choose Nummer</option>
<option ng:repeat="number in Numbers" value="{{number}}">{{number}}</option>
<!-- Select month -->
</select>
</div>
<div class="col-md-4 col-xs-12">
<select name="objDesc" class="form-control" ng-model="ObjektDescriptions" ng-change="listSearchChnage(ObjektDescriptions,'objektDescription')">
<option value="">Choose something</option>
<option ng:repeat="desc in ObjektDescriptions" value="{{desc}}">{{desc}}</option>
<!-- Select month -->
</select>
</div>
<div class="col-md-4 col-xs-12">
<select name="tenantName" class="form-control" ng-model="CustomerNames" ng-change="listSearchChnage(CustomerNames,'customerName')" >
<option value="">Choose somethingelse</option>
<option ng:repeat="customerName in CustomerNames" value="{{customerName}}">{{customerName}}</option>
</select>
</div>
<div class="col-md-4 col-xs-12">
<select name="dateSearch" class="form-control" ng-model="RegisterDates" ng-change="listSearchChnage(RegisterDates,'registerDate')" >
<option value="">Choose somethingelse</option>
<option ng:repeat="date in RegisterDates" value="{{date}}">{{date}}</option>
<!-- Select month -->
</select>
</div>
<div class="col-md-4 col-xs-12">
<select name="managerSearch" class="form-control" ng-model="Managers" ng-change="listSearchChnage(Managers,'manager')">
<option value="">Choose somethingelse</option>
<option ng:repeat="manager in Managers" value="{{status}}">{{manager}}</option>
<!-- Select month -->
</select>
</div>
<div class="col-md-4 col-xs-12">
<select name="advStatusSearch" class="form-control" ng-model="AdvStatuses" ng-change="listSearchChnage(AdvStatuses,'s')">
<option value="">Choose Status</option>
<option ng:repeat="s in AdvStatuses" value="{{s}}">{{s}}</option>
<!-- Select month -->
</select>
</div>
除了呈现“状态”的最后一个列表之外的所有列表都将其第一个选项选为默认选项。
我已经尝试过硬编码选择属性“selected = selected”但是没有用。我甚至试过通过脚本设置它:
$.each(data, function(i, v) {
$scope.Numbers.push(v.orderraderid);
if ($.inArray($.trim(v.orderraderid), $scope.Numbers) == -1)
$scope.Numbers.push(v.orderraderid);
if ($.inArray($.trim(v.objektbeteckning), $scope.ObjektDescriptions) == -1)
$scope.ObjektDescriptions.push(v.objektbeteckning);
if ($.inArray(v.kundnamn, $scope.CustomerNames) == -1)
$scope.CustomerNames.push(v.kundnamn);
if ($.inArray(v.anmdatum, $scope.RegisterDates) == -1)
$scope.RegisterDates.push(v.anmdatum);
if ($.inArray($.trim(v.status), $scope.AdvStatuses) == -1)
$scope.AdvStatuses.push(v.status);
if ($.inArray($.trim(v.utforare), $scope.Managers) == -1)
$scope.Managers.push(v.utforare);
});
但没有任何作用。我究竟做错了什么?
答案 0 :(得分:0)
我花了一段时间,但我改变了
<option ng:repeat="status in AdvStatuses" value="{{status}}">{{status}}</option>
要
<option ng:repeat="status in AdvStatuses" value="">{{status}}</option>
它解决了这个问题。我真的不明白为什么会发生这种情况,并且如果有人的话,我会很感激吗?