我根据以前的解决方案创建了一个带有替代过滤器的要点:
https ://gist.github.com/360disrupt/1432ee1cd1685a0baf8967dc70ae14b1
该过滤器扩展了现有的角度过滤器:
angular.module 'tsd.orderByEmptyLast', []
.filter 'orderByEmptyLast', ($filter) ->
return (list, predicate, reverse)->
orderedList = $filter('orderBy')(list, if reverse then ['!' + predicate, '-' + predicate] else ['!' + predicate, predicate] )
return orderedList
在较新的角度版本上,您可能需要包含orderByFilter
而不是使用 $filter
angular.module 'tsd.orderByEmptyLast', ['orderByFilter']
.filter 'orderByEmptyLast', () ->
return (list, predicate, reverse)->
orderedList = orderByFilter(list, if reverse then ['!' + predicate, '-' + predicate] else ['!' + predicate, predicate] )
return orderedList