api返回状态,分配给动态来的$scope.status
$scope.status = [{"planStatus":"Completed","records":2},{"planStatus":"Partial","records":22},{"planStatus":"Active","records":24},{"planStatus":"Merged","records":6}]
这是我使用ng-repeat
创建select box
的html代码
<select ng-options="sta.planStatus as sta.planStatus for sta in status" ng-model="plan.planStatus" class="form-control">
<option class="selectoption" value="">Select Status</option>
</select>
我在我的选择框中创建了一个select box
,5个选项
我想从html中删除一个选项(如Active)?我该怎么做?可以不做变更api响应
答案 0 :(得分:1)
您可以使用角度过滤器删除选项。要删除planStatus为“活动”的选项,请尝试此操作。
ng-options="sta.planStatus as sta.planStatus for sta in status | filter: optionsFilter"
在控制器中:
$scope.optionsFilter = function (option) {
if (option.planStatus == 'Active') {
return false;
}
return true;
}