【发布时间】:2017-11-03 15:48:22
【问题描述】:
我正在使用 angularjs 填充如下表格:
<table>
<thead>
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
<th>col5</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows">
<td>{{row.col1}}</td>
<td>{{row.col2}}</td>
<td>{{row.col3}}</td>
<td>{{row.col4}}</td>
<td>{{row.col5}}</td>
</tr>
</tbody>
</table>
因为该表有很多通常不包含值 (NULL) 的列,所以我想隐藏这些列。
注意:所有行的该列值为 NULL。
示例(row.col1=NULL、row.col3=NULL):
<table>
<thead>
<tr>
<th>col2</th>
<th>col4</th>
<th>col5</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows">
<td>{{row.col2}}</td>
<td>{{row.col4}}</td>
<td>{{row.col5}}</td>
</tr>
</tbody>
</table>
到目前为止,我无法找到/找出解决方案。
我开始相信这是不可能的......
【问题讨论】:
-
你可以使用 ng-if,正如这个问题stackoverflow.com/questions/23465835/…所描述的那样
-
我也找到了答案,但这是一个非常简单的例子。它只有 1 行,没有表头...
-
@udo 你检查我的 plunk 了吗?
-
道歉。我周末不在。我只能检查星期一:|
-
@dev8080,您的代码有效。好的。谢谢!
标签: angularjs html-table