我得到了一个包含数据的数组。 现在我正在使用 AngularJS 动态创建一个 html 表。
显示了数组中的数据,但是二维数组中也有空字符串,像:
array = [[""],["name"],[""],["name2"]]
有没有办法显示空表格单元格?
像这样我的表格数据被移动了。
如果有帮助:
var template = `
<table class="objList" >
<tr data-ng-repeat="z in colStorageItems | orderBy: \'-name\' track by $index">
<th class = "col" data-ng-repeat="y in z | orderBy: \'name\' track by $index">
{{y}}
</th>
</tr>
</table>
`;
谢谢
最佳答案
您可以使用 if ng-if
从呈现的 html 中过滤空项目/行。
<tr ng-repeat="item in items " ng-if="item.dataField">
<!-- Content of tr, item.dataField is not not "empty"-->
</tr>
关于javascript - 空表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53764038/