1
    {{#each compareDataRaw as |row index|}}
      {{log compareDesigns.[index]}}

      {{rr/bar-chart
        chartId=(concat "chart" index)
        data=row
      }}
    {{end}}

I am trying to get the element from compareDesigns array with no luck?

I have also tried snippet below with the same context with the same outcome undefined.

{{log compareDesigns.index}}

2 Answers 2

3

Use get helper

{{get compareDesigns (concat index) }}
Sign up to request clarification or add additional context in comments.

8 Comments

compareDesigns is an array. I think i need a custom helper instead
we need to pass string so using concat helper to convert it.. try my updated one
It does not work. It converts the entire array into a huge string. I do not think get works for an array.
check in this twiddle its working for array of string and for array of object too
Yes, your solution did work. Twitter. Then there must be something wrong with the data. Thanks
|
0

I have also created my own custom helper. (Not sure if this is redundant)

ember g helper array-at

Inside the array-at.js file,

import Ember from 'ember';

export function arrayAt(params/*, hash*/) {
  const arr = params[0];
  const index = params[1];
  return arr[index];
}

export default Ember.Helper.helper(arrayAt);

Inside the template file,

{{#each compareDataRaw as |row index|}}
  {{array-at compareDesigns index}}

  {{rr/bar-chart
    data=row
  }}
{{/each}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.