【发布时间】:2015-08-17 03:42:15
【问题描述】:
我正在尝试使用 Angularjs 过滤器过滤 json 数据列表 (https://api.myjson.com/bins/5a2aw)。当我只使用过滤器时,不会发生精确匹配,并且 1 显示 id = 1、10、11、12 的结果。将 true 与过滤器一起使用非常奇怪,所有 id 都会出现一个 id 为 7 的结果。
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="x in names | filter : true : {id: 7}">
{{x.Name+ " " + x.Quote}}
</li>
</ul>
</div>
</body>
<script>
var app = angular.module('myApp',[])
app.controller('myCtrl',function($scope, $http){
$http.get("https://api.myjson.com/bins/5a2aw").success(function(response) {$scope.names=response.records;});
});
</script>
</html>
【问题讨论】:
标签: javascript angularjs search