javascript - How can we use filter in ng-repeat when iterating on an object in AngularJs -


search field binded model

<input type="text" ng-model="searchvoucher" /> 

an object iterated in ng-repeat

<li ng-repeat="(k,f) in {'r':4,'e':5,'t':6,'y':7,'c':8} | filter:searchvoucher">{{f}}</li> 

how can filter based on object's key or val or val can object having attributes.

please help

try

<li ng-repeat="(k,f) in {'r':4,'e':5,'t':6,'y':7,'c':8} | searchfilter:searchvoucher">{{f}}</li> 

filter

app.filter('searchfilter', function() {   return function(input, term) {     var regex = new regexp(term || '', 'i');     var obj = {};     angular.foreach(input, function(v, i){       if(regex.test(v + '')){         obj[i]=v;       }     });     return obj;   }; }); 

demo: plunker


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -