How to make orderby filter work on array of strings?

前端 未结 2 1716
长发绾君心
长发绾君心 2020-12-01 02:51

Here is the code which is not working: Demo: http://jsfiddle.net/8dt94/63/

相关标签:
2条回答
  • 2020-12-01 02:58

    You can order by a method, so you can use the toString method

    <ul ng-repeat="strVal in arrVal | orderBy:'toString()' | filter:searchText">
    
    0 讨论(0)
  • 2020-12-01 02:58

    Write a custom filter:

    app.filter('mySort', function() {
        return function(input) {
          return input.sort();
        }
      });
    

    HTML:

    <ul ng-repeat="strVal in arrVal|filter:searchText|mySort">
    

    Fiddle.

    0 讨论(0)
提交回复
热议问题