× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

AngularJS Custom Filter by Tags

Stepan Suvorov
Apr 11, 2015
<pre><code class="language-javascript">app.filter('tagsFilter', function () { return function (items, tags) { var filtered = []; (items || []).forEach(function (item) { var matches = tags.every(function (tag) { return (item.tags.indexOf(tag) &gt; -1); }); if (matches) { filtered.push(item); } }); return filtered; }; }); </code></pre> <p> </p> <p><a href="http://jsfiddle.net/STEVER/d5ra41dq/">Fiddle</a> to play with a code.</p> <p> </p> <p> </p>
comments powered by Disqus