Angularjs 如果在ng内使用ng,则重复显示表格中的按钮
hello guyz在上图中,如果字符isDead=true但按钮不显示,我尝试显示一个按钮。这是我的密码:Angularjs 如果在ng内使用ng,则重复显示表格中的按钮,angularjs,Angularjs,hello guyz在上图中,如果字符isDead=true但按钮不显示,我尝试显示一个按钮。这是我的密码: <table class="table table-striped table-bordered"> <thead> <tr> <th>Name</th> <th>Age</t
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>isDead</th>
<th>Resurrect</th>
<th>Increase Age</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr ng-hide="products.length">
<td colspan="3" class="text-center">No Data</td>
</tr>
<tr ng-repeat="item in products">
<td>{{item.name}}</td>
<td>{{item.age}}</td>
<td>{{item.isDead}}</td>
<td ng-if="item.isDead == 'true' ">
<button class="btn btn-success">Resurrect</button>
</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
名称
年龄
死亡
使复兴
增龄
细节
没有数据
{{item.name}
{{item.age}
{{item.isDead}
使复兴
感谢您的帮助转换此文件
<td ng-if="item.isDead == 'true' ">
对此
<td ng-if="item.isDead">
N:B:在td
中使用ng if
将破坏您的html。转换此内容
<td ng-if="item.isDead == 'true' ">
对此
<td ng-if="item.isDead">
N:B:在
td
中使用ng if
将破坏您的html。我不清楚item.isDead的值是什么,但如果它是布尔值,而不是一个文本表示形式,那么您只需使用:
ng-if="item.isDead"
这是因为这是对真/假的评估,item.ishead已经提供了这一点
此外,对于将输出的HTML,您应更改为:
<td>
<button class="btn btn-success" ng-if="item.isDead">Resurrect</button>
</td>
使复兴
否则,在item.isDead为true的项目上,您将得到不匹配的列,因为这些行上会少一个单元格。我不清楚item.isDead的值是什么,但如果它是布尔值,而不是一个文本表示,那么您只需使用:
ng-if="item.isDead"
这是因为这是对真/假的评估,item.ishead已经提供了这一点
此外,对于将输出的HTML,您应更改为:
<td>
<button class="btn btn-success" ng-if="item.isDead">Resurrect</button>
</td>
使复兴
否则,在item.ishead为true的项目上,您将得到不匹配的列,因为这些行上会少一个单元格。最好像这样使用ng show:
<td ng-show="item.isDead">
对于设计,最好在按钮元素上使用ng show。最好像这样使用ng show:
<td ng-show="item.isDead">
或者更好的设计是在按钮元素上使用ng show。感谢信息感谢信息一些简短摘要为什么/何时使用ng如果以及何时使用ng show或ng hide一些简短摘要为什么/何时使用ng如果以及何时使用ng show或ng hide