2017-07-25 122 views
0

我就給列計算列角材料MD-數據表就像一個計算列{{desserts.value1/desserts.value2}}如何通過MD-訂單

<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

你使用這個[模塊](https://github.com/daniel-nagy/md-data-table)? – JeanJacques

+0

是https://github.com/daniel-nagy/md-data-table –

回答

0

當我單獨給出它的價值而沒有反對意見時,它會花費。即((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>