我的专栏是一个计算列,例如{{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中给出什么,通常我可以给出属性名称。
答案 0 :(得分:0)
当我单独给出它没有物体的价值时,它将需要。 ie((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>