question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

using trackby on object

See original GitHub issue

API response returns an object with nested attributes for each option. How can I tell track-by to use an object property? i.e. track-by="attributes.language"

Example here: https://jsfiddle.net/fy18zy9b/3/

<multiselect 
v-model="value" 
:options="options"
    :multiple="true"
    track-by="attributes.language"
    :custom-label="customLabel"
    >
  </multiselect>

Sample options:

[
  {
    attributes: 
    {
      language : 'JavaScript', 
      library: 'Vue.js'
    }
  },
  {
    attributes: 
    {
      language : 'JavaScript', 
      library: 'Vue-Multiselect'
    }
  },
  {
    attributes: 
    {
      language : 'JavaScript', 
      library: 'Vuelidate'
    }
  },
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:5

github_iconTop GitHub Comments

7reactions
marcotoldocommented, Oct 25, 2019

+1

Would be great to have any prop ‘customTrackBy’ (Function => String) like ‘customLabel’ so as to work with any nested object

1reaction
BabOuDevcommented, Oct 31, 2019

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use `trackBy` with `ngFor` - angular - Stack Overflow
Based on some examples I've seen on the web, I should return the value of some property on the object. Is it right?...
Read more >
When, Why and How to Use Trackby - DLT Labs - Medium
It's a core directive that comes with Angular framework itself. It makes it easy to iterate over something like an array or an...
Read more >
Angular Basics: Track Incoming Data With TrackBy Method
TrackBy is a directive that can work with ngFor to identify items in a list of DOM elements like a list or array...
Read more >
How to use trackBy in Angular with Example - Codebriefly
The trackBy function takes two arguments, the first is the index and the second one is the current item. That will return one...
Read more >
Explain ngFor trackBy in Angular - Simple Talk
At the; end of this blog, you will understand how to use ngFor trackBy and when to use the ngFor trackBy in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found