【问题标题】:How to give calculated columns in Angular Material md-data-table with md-order-by如何使用 md-order-by 在 Angular Material md-data-table 中给出计算列
【发布时间】:2017-07-25 08:41:56
【问题描述】:

我的列是一个计算列,例如 {{desserts.value1/desserts.value2}}

 <md-table-container>
  <table md-table>
    <thead md-head md-order="myOrder">
      <th md-column md-order-by="value1">Dessert (100g serving)</th>
      <th md-column md-order-by="????">Calories</th>
    </thead>
    <tbody md-body>
      <!-- we can let ng-repeat sort the columns for us -->
      <tr ng-repeat="dessert in desserts | orderBy: myOrder">
        <td>{{ dessert.value1}}</td>
        <td>{{ (dessert.value1 == 0)?0 : dessert.value2)}}</td>
    </tr>
    </tbody>
  </table>
</md-table-container>

我想订购该列,所以我应该在 md-order-by 中给出什么,通常我可以给出属性名称。

【问题讨论】:

标签: angularjs material-design


【解决方案1】:

当我单独给出它的价值而没有对象时,它会采取。即 ((value1==0)?0:value2)

<md-table-container>
  <table md-table>
    <thead md-head md-order="myOrder">
      <th md-column md-order-by="value1">Dessert (100g serving)</th>
      <th md-column md-order-by="(value1 == 0)?0 : value2)">Calories</th>
    </thead>
    <tbody md-body>
      <!-- we can let ng-repeat sort the columns for us -->
      <tr ng-repeat="dessert in desserts | orderBy: myOrder">
        <td>{{ dessert.value1}}</td>
        <td>{{ (dessert.value1 == 0)?0 : dessert.value2)}}</td>
    </tr>
    </tbody>
  </table>
</md-table-container>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-03
    • 2014-11-29
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 1970-01-01
    相关资源
    最近更新 更多