基于 html 页面上其他地方的值,我需要表格中的一行来显示比表格中其他地方更多的单元格。为了保持对齐正确并且一切都干净,我正在寻找一种使用 Angular 动态设置单元格的 colspan 的方法。我似乎无法正常工作。
<input type="checkbox" ng-model="vm.noInventory"/>
<table>
<th>
<td>Product</td>
<td colspan={{vm.noInventory ? '2' : '1'}}>Inventory<td>
<td ng-show="vm.noInventory"></td>
</tr>
<tr>
<td>Product B</td>
<td>55 parts</td>
<td ng-show="vm.noInventory">Backordered</td>
</tr>
</table>
最佳答案
找到解决方案...我实际上有错字,需要在 colspan 中包含“”...
<td colspan="{{vm.noInventory ? '2' : '1'}}">Inventory<td>
关于html - 如何使用 Angular 将单元格 colspan 基于条件值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36293558/