html - 如何使用 Angular 将单元格 colspan 基于条件值?

标签 html angularjs conditional html-table inline

基于 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/

相关文章:

SQL 条件列存在

html - 为什么我的空 div 在使用 display inline 时有宽度但会折叠?

php - 使用 php 在 mysql 中插入带有标题和详细信息的照片

javascript - 无法从 codenvy 预览/运行 angular.js 项目

css - 在 bootstrap 网格中使用边距和填充

C++ 条件运算符与 if-else

JavaScript YAML 解析器

html - 如何在过滤器上方带有文本的图像上放置透视过滤器

javascript - Angular Material 日期选择器尺寸错误

ruby - 以有条件的方式构建哈希