使用搜索栏过滤列中有重复条目的区分大小写的数据,并返回特定的行AngularJS

Filter a case-sensitive data with duplicate entry in a column using search bar and return that particular row AngularJS

本文关键字:数据 大小写 返回 AngularJS 过滤 搜索栏      更新时间:2023-09-26

我的解决方案:AngularJS-搜索表-筛选器表格,td{边框:1px纯灰色;边界塌陷:塌陷;填充:5px;}

<body>
<div ng-app="myApp" ng-controller="namesCtrl"/> 
<p>Filtering input:</p>    
<p><input type="text" data-ng-model="search.City"></p>
<table>
  <tr data-ng-repeat="x in names | filter: search: strict ">
    <td> {{ x.Name }}</td>
    <td>{{ x.City }} </td>
    <td> {{ x.Country }}</td>
  </tr>
</table> 
<p>{{ City | lowercase }}</p>
<script>
var app = angular.module('myApp', []);
app.controller('namesCtrl', function($scope, $http) {
    $http.get("names.js")
    .success(function (response) {$scope.names = response.records;});
});
</script>
</body>
</html>
The above code displays the data from the table from the column "City". But I have a duplicate like,"Sao" and "sao". When the user searches for "Sao" the returned value should be the row of data which contains "Sao" as the city.

在搜索之前单击此处查看解决方案

点击此处查看过滤后的

看看其他帖子提供的答案。

https://stackoverflow.com/a/24798741/6654503

您还可以根据上述答案更新比较器功能(如果需要),以满足您的需求。