我正在HTML中使用ng-repeat在javascript数组上循环。在选择中显示此数组。 我想要做的就是按下按钮时清除这些下拉列表中的所有选定数据
HTML
E474: invalid argument: listchars=tab:>-,eol:$,space:<a1><a4>
angularjs
<div class="widget-title">
<div class="widget-controls">
<button class="btn btn-xs btn-primary" ng-click="newassignment()">New</button>
<button class="btn btn-xs btn-success" ng-click="saveavd()">Save</button>
</div>
<h3><i class="icon-ok-sign"></i>Assignment</h3>
</div>
<div id="vacation" class="widget-content" style="height:81vh; overflow:auto;">
<div class="row">
<table style="width: 70%;" border="1">
<thead>
<tr>
<th>Departments</th>
<th>Work Level</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="d in departments | filter : depts">
<td>
<input style=" margin-top: 0;" type="checkbox" ng-model="d.details"/> {{d.Dep_LDesc}}
</td>
<td>
<select class="form-control input-sm" ng-model="wrklevel2">
<option ng-repeat="w in worklevel" value="{{w.lvlid}}">{{w.lvlnm}}</option>
</select>
</td>
</tr>
</tbody>
</table>
答案 0 :(得分:1)
您应在ng-repeat中选择不同的模型,以实现可以尝试以下操作
( ng-model =“ d.wrklevel2” )
<select class="form-control input-sm" ng-model="d.wrklevel2">
<option ng-repeat="w in worklevel" value="{{w.lvlid}}">{{w.lvlnm}}</option>
</select>
之后,您还可以清除forEach循环内的select值
angular.forEach($scope.departments, function (d) {
d.details = false;
d.wrklevel2 = undefined;
})
答案 1 :(得分:0)
将select
的ngModel设置为空字符串-
function saveavd()
{
$scope.wrklevel2 = ""
// ...
}