Reputation: 3854
In the below code its working for both filters. For example if I give
<li ng-repeat="list in arr | filter:DegreeName='masters'">
or
<li ng-repeat="list in arr | filter:DegreeName='certificate'">
I get the result which is not expected. May be some silly mistake but I am not able to figure out.
html
<div ng-controller="MyCtrl">
<li ng-repeat="list in arr | filter:DegreeName='masters'">
{{list.Name}}-{{list.DegreeName}} - {{list.DegreeCode}}{{list.URL}}
</li>
</div>
JS
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
alert();
$scope.arr = [{"URL":"/online-degrees/certificate-nursing-education","NavKey":"certificate-nursing-education","Name":"Nursing Education","AOS":"Nursing","DegreeName":"certificate","DegreeCode":"CERT","LearningFormat":"Structured","DegreeTitle":"Post-Masters Certificate"}];
}
Upvotes: 2
Views: 3518
Reputation: 136144
You should be specifying data to be match in JSON format.
<li ng-repeat="list in arr | filter: {DegreeName: 'masters'}">
You could pass equality check value to true
, if you want to filter those many value which are exactly matching with text. But as I can see the 1st part of the solution would be appropriate for your scenario.
<li ng-repeat="list in arr | filter: {DegreeName: 'masters'}: true">
Upvotes: 3