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响应
您可以使用角度过滤器来删除选项。要删除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;
}