下面的静态示例按名字排序,但禁用了对电子邮件列的排序:
<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的列设置为可排序?
发布于 2015-06-25 13:12:50
我建议您在内部元素上设置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>如果您不想重复自己,可以将此逻辑嵌入到指令中
https://stackoverflow.com/questions/30800390
复制相似问题