我想有以下3列的表格,代码看起来像这样显示表行,如果数据存在
<table class="table-striped table-bordered table-condensed">
<tbody>
<tr ng-if="$index%3==0" ng-repeat="permission in vm.parent.getAllPermissions(category)">
<td ng-repeat="i in [0,1,2]" class="col-xs-2">
<span>
<input type="checkbox" checklist-model="vm.data.permissions" checklist-value="vm.parent.getPermission(category,$parent.$index+i)"> {{vm.parent.getPermissionTitle(category,$parent.$index+i) || " "}}
</span>
</td>
</tr>
</tbody>
</table>
这一工程,除了一个小问题大。
有根本没有足够的JSON数据,以填补3行,因此2个复选框显示空
我试过了,正在写一些东西像
vm.hasPermission = function(category, index) {
var permissions = vm.getAllPermissions(category);
return permissions && index < permissions.length
};
然后像
<span>
<input ng-if="vm.parent.hasPermission(category,$parent.$index+i)"type="checkbox"
checklist-model="vm.data.permissions" checklist-
value="vm.parent.getPermission(category,$parent.$index+i)"> {{vm.parent.getPermissionTitle(category,$parent.$index+i) || " "}}
</span>
它修复了问题,但不是在所有的表格上,有些表格仍然会有空的复选框。
我得到这样
vm.getPermissionTitle = function(category, index) {
var permissions = vm.getAllPermissions(category);
if (index < permissions.length) {
return i18n.get(permissions[index]);
} else {
return '';
}
};
我试图消除返回许可标题,并没有解决它。
我将不胜感激修复而无需额外的依赖,就像NG-表。 – Lynob
请你举个实例吗? –
并用DIV替换SPAN来检查? –