如何根据条件使用ng-if和table显示td
参考之前关于DIV中ng-if的文章以,但是当我在ng-repeat表上尝试ng-if并在td上使用ng-repeat时,似乎没有做得好。如果我错了,请纠正我,我根据条件尝试进行2次显示该列,但均无效果。下面我给出了代码以供参考。有人可以帮我这个忙。请告知是否需要进一步说明。
<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>
<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>
回答:
ng-if
应该为您工作 。这是小提琴的工作示例
http://jsfiddle.net/shivaraj/n3xWB/
以上是 如何根据条件使用ng-if和table显示td 的全部内容, 来源链接: utcz.com/qa/421544.html