0

下面的静态示例对名字进行了排序,但对电子邮件列禁用了排序:

<tr>
    <th st-sort="firstName">first name</th>
    <th>email</th>
</tr>

但是,我的专栏是动态的。所以我在ng-repeat. 列是否可排序由isSortable标志决定。

     <tr>
        <th st-sort="column.isSortable" ng-repeat="column in columns">{{column.columnName}}</th>
    </tr>

如何仅使isSortable设置为true可排序的列?

4

1 回答 1

-1

我建议您将 st-sort 设置在内部元素上

   <tr>
    <th ng-repeat="column in columns"><span st-sort="column.sortProperty" ng-if="column.isSortable">{{column.columnName}}</span><span ng-if="!column.isSortable">{{column.columnName}}</span></th></tr>

如果你不想重复自己,你可以在指令中嵌入这个逻辑

于 2015-06-25T05:12:50.047 回答