I have items to search by title(string) or tags(array of strings)
items:
[
{
title: 'My title',
tags: ['tag1', 'other']
},
{
title: 'Misc',
tags: ['tag1', 'notag']
}
]
I want one input to search in title OR tags
In my template, this works well :
<form>
<input type="text" ng-model="query">
</form>
<li ng-repeat="item in items | filter:query:title | filter:query:tags">
<p>{{item.title}}</p>
</li>
All my items are shown and if I enter text, it filter by title or tags.
ex:
I type title
, only the first item is returned and if I type tag1
, both are returned.
Now, I need to have an other scope with the results of that search filter.
In my controller/directive, I tryied :
scope.filteredItems = $filter('filter')($filter('filter')(scope.items, {title: scope.query}), {tags: scope.query});
But I don't have the same results, what did I miss?