how to use orderBy and filterBy together ?
8lbiasian opened this issue · comments
8lbiasian commented
hello,
i have following
buttons
<button @click="ordby('likes')">Sort by likes</button>
<button>all</button>
<button>image</button>
<button>video</button>
and my code is following
<div v-for="(value, key) in orderBy(obj,this.ord,-1)">
<p>Likes: {{value.likes}}</p>
<p>Type: {{value.type}}</p>
</div>
so at the moment i can do the order by depend on likes when i click on the sort by likes but how i can do the filter also
is it possible to add the filterBy also in the v-for along with orderBy ??
and I have 3 conditions where I need to show all or show image or video
thanks in advance
Aleksandr Statciuk commented
Hello,
To make things a little easier you can simply use filters programmatically, like so:
this.filterBy(this.items, this.filter, 'type')
This will give you the ability to easily change both the filter and the order. Here is a small example: https://codepen.io/Arhey/pen/eoZpmG
8lbiasian commented
great work perfectly ^^
thanks.