Aru*_*run 10 angularjs angular-ng-if
参考早期关于ng-if在DIV中的帖子以供参考此处给出的链接:: Ng-If如果在DIV内,但是当我尝试使用ng-if在ng-repeat on td内表时,它似乎没有工作得很好.纠正我,如果我错了我根据条件做了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>
Run Code Online (Sandbox Code Playgroud)
试试:: 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>
Run Code Online (Sandbox Code Playgroud)
如果表结构的格式不正确,大多数浏览器将忽略表结构中的任何其他 DOM 元素。这意味着,在上面的代码中,您不能div在tr. 试试这个
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
81195 次 |
| 最近记录: |