javascript - how to skip value in ng-repeat if it is already in another list? -
i have, example, person data tags following:
$scope.person.groups = ['ios'] and tags list:
$scope.tagslist = ['android', 'ios', 'pm'] how display ['android', 'pm'] ng-repeat?
i tried:
<li ng-repeat="tag in tagslist" ng-show="tag != person.groups">{{tag}}</li> but didn't work.
how display records not in second array?
you should use filter. here's how can it:
html:
<li ng-repeat="tag in tagslist | arrfilter: person.groups">{{tag}}</li> filter:
app.filter('arrfilter', function() { return function(collection, person) { var output = []; angular.foreach(collection, function(item) { if(person.indexof(item) == -1) { output.push(item); } }) return output; } })
Comments
Post a Comment