[Vuejs]-Creating dropdown and populating unique value in Vue js

0👍

Use the following computed property to get the list of unique Type values:

computed:
{
  onlyTypes()
  {
    // we want an Array with all the Type values
    return this.tableDataRows.map(dataItem => dataItem.type);
  },
  uniqueTypes()
  {
    // we want only the unique Type values
    return this.onlyTypes.filter((value, index, self) => self.indexOf(value) === index);
  }
}

Leave a comment