AngularJs, filter case insensitive

后端 未结 2 734
遇见更好的自我
遇见更好的自我 2020-12-06 18:13

I\'ve got an json full of datas with lowcase and upcase. For example :

[

  { \"firstName\":\"JoHn\" , \"lastName\":\"DoE\" }, 
  { \"firstName\":\"aNnA\" ,          


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 18:42

    Pass a function name to filter which you define on an applicable scope, where you use string's toLowerCase. See ngFilter. The function signature is a simple function (item) { ... }.

    Example JS in your controller:

    $scope.filterOnlyFoo = function (item) {
        return item == "foo";
    }
    

    Example HTML:

    Sample Plunker

提交回复
热议问题