user7632814
user7632814

Reputation:

How to extract certain value from a collection of ember data?

Code below is my current solution,

  tagsValue: Ember.computed('tags.@each', {
    get() {
      const out = [];
      this.get('tags').forEach((tag) => {
        out.push(tag.get('value'));
      });
      return out;
    }
  }),

Is there a better way to do so?

Upvotes: 0

Views: 23

Answers (1)

XYZ
XYZ

Reputation: 27397

Try code below,

  tagsValue: Ember.computed('tags.@each', {
    get() {
      return this.get('tags').mapBy('value');
    }
  }),

Upvotes: 1

Related Questions