I created a select
element in HTML
and want to create an option for a user to sort a table by select element option values
.
The data
I want to sort (there will be many objects):
I am watching a select element which has a v-model value of sort:
watch: {
search: function (val) {
if (val.length === 0) return this.filtered = this.affiliates;
this.filtered = this.affiliates.filter(function (cont) {
return cont.shop_name.toLowerCase().indexOf(val.toLowerCase()) >= 0 || cont.app_name.toLowerCase().indexOf(val.toLowerCase()) >= 0;
});
},
sort: function (val) {
console.log(this.filtered);
},
How could I sort objects
by watched value?
Data is stored in this.filtered
I want to sort by these values:
<select v-model="sort">
<option value="date_installed">Latest</option>
<option value="status">Status</option>
<option value="share">Share</option>
</select>