【发布时间】:2015-05-18 17:43:05
【问题描述】:
我有一个正在显示的图层列表:
<tr ng-repeat="row in layers | filter:isActive | orderBy:row.name">
<td><input type="radio" id="{{ 'layerOption-' + row.key }}" name="layerOptions" ng-checked="row.checked" /></td>
<td>{{ row.name }}</td>
<td></td>
</tr>
我通过以下方式获取列表:
$scope.isActive = function(layer) { return layer.zoned === $scope.showZonedLayers; };
$scope.layers = values.layers.map(function(item, key) { return {
key: key,
name: item,
checked: key === 0 ? true : false,
zoned: item.indexOf("Zones") > 0
} });
这将设置列表集中的第一个元素,但这可以被过滤器过滤掉。如何将第一个未过滤/可见的单选框设置为选中?
这可以通过过滤器完成吗?如果不是,那么 Angular 与 jquery grep 的等价物是什么?
【问题讨论】:
标签: angularjs filter radio-button ng-repeat