参考之前关于 ng-if in DIV 的帖子以供参考此处给出的链接 :: Ng-If inside DIV,但是当我尝试使用 ng-if inside table 和 td 上的 ng-repeat 时似乎没有运作良好。如果我错了,请纠正我我做了 2 次尝试根据条件显示列,但没有一个有效。下面我给出了代码供参考。有人可以帮我解决这个问题。如果您需要更多说明,请告知。
HTML
试试 :: 1
<table>
<tr ng-repeat = "data in comments">
<td ng-if="data.type == 'hootsslllll' ">
//differnt template with hoot data
</td>
<td ng-if="data.type == 'story' ">
//differnt template with story data
</td>
<td ng-if="data.type == 'article' ">
//differnt template with article data
</td>
</tr>
</table>
试试 :: 2
<table>
<tr ng-repeat = "data in comments">
<div ng-if="data.type == 'hootsslllll' ">
<td> //differnt template with hoot data </td>
</div>
<div ng-if="data.type == 'story' ">
<td> //differnt template with story data </td>
</div>
<div ng-if="data.type == 'article' ">
<td> //differnt template with article data </td>
</div>
</tr>
</table>