i'm trying filter list of json data (https://api.myjson.com/bins/5a2aw) using angularjs filter. when use filter exact matching not take place , 1 shows results id = 1,10,11,12. using true filter though works weirdly, single result id 7 appears ids.
<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>
you should put true
(which exact check) after filter
criteria, not @ 1st place of filter.
markup
<li ng-repeat="x in names | filter : {id: 7}: true "> {{x.name+ " " + x.quote}} </li>
syntax
{{ filter_expression | filter : expression : comparator}}
Comments
Post a Comment