如何在智能表中按日期对数据进行排序?有了st-sort,它就不那么好了.
<table st-table="displayedCollection" st-safe-src="playerCollection" class="table table-hover"> <thead> <tr> <th st-sort="id" class="hover">Id</th> <th st-sort="firstname" class="hover">Jméno</th> <th st-sort="lastname" class="hover">Příjmení</th> <th st-sort="registrationDate" class="hover">Datum registrace</th> </tr> </thead> <tbody> <tr ng-repeat="player in displayedCollection"> <td class="hover">{{player.id}}</td> <td class="hover">{{player.firstname}}</td> <td class="hover">{{player.lastname}}</td> <td class="hover">{{player.registrationDate}}</td> </tr> </tbody> </table>
谢谢你的回答.
解决方法
它通常应该工作(参见文档网站).但是,如果您的注册日期是日期字符串,则应使用getter返回其日期对象版本,否则您将获得alphaNumeric命令
在你的控制器中
$scope.getters = { registrationDate:function(row) { return new Date(row.registrationDate); } }
所以你可以将你的标题绑定到这个getter
<th st-sort="getters.registrationDate">Datum registrace</th>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。