如何角度Js搜索不区分大小写

时间:2017-06-16 11:26:02

标签: javascript html angularjs

HTML代码:

<input type="search" name="search" placeholder="Search for members in first name,last name and email" ng-model="query" class="form-control input-box"> <tr ng-repeat="item in filterData = (totalItems| filter : search) | limitTo:10:10*(page-1)" ng-cloak> </tr>

JS代码:

$scope.search = function (row) { return !!(( row.member_fname.indexOf($scope.query || '') !== - 1 || row.member_lname.indexOf($scope.query || '') !== - 1 || row.member_email.indexOf($scope.query || '') !== - 1)); };

1 个答案:

答案 0 :(得分:0)

更新您的JS代码

$scope.search = function (row) { var query = $scope.query || ''; return !!(( row.member_fname.toLowerCase().indexOf(query.toLowerCase()) !== - 1 || row.member_lname.toLowerCase().indexOf(query.toLowerCase()) !== - 1 || row.member_email.toLowerCase().indexOf(query.toLowerCase()) !== - 1)); };