2

fiddle

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"}];
}

1 Answer 1

3

You should be specifying data to be match in JSON format.

<li ng-repeat="list in arr | filter: {DegreeName: 'masters'}">

Working Fiddle


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">
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks but what was the issue and why was it working randomly
its breaking when I am using multiple filters like on is custom filter example list in doctorallist = (arr | programListingFilter:map | filter:{DegreeName='doctoral'}) here programListingFilter:map return some list from that I need to filter by doctoral
What is programListingFilter:map
check my code i added. map is array of indices [0,2,3,2] etc
sorry ignore it was some other issue I fixed. Thanks for heads up.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.