0

So I have these two data structures that I need to loop over and both of these will output the expected values

{{#each viewData.activity}}
    {{label}}<br/>
{{/each}}
<hr>
{{#each viewData.maxActivity}}
    {{label}}<br/>
{{/each}}

But I need to perform the following loop but it's not working as I have it below:

{{#each viewData.activity}}
    {{label}}<br/>
    {{../viewData.maxActivity.label}}<br/>
{{/each}}

The ../ should be working but it isn't. What am I missing?

I found in another SO post (https://stackoverflow.com/a/26341035/483140) and have the following working but doesn't seem efficient:

{{#each .}}
    {{#activity}}{{activityLabel}}{{/activity}}<br/>
    {{#maxActivity}}{{activityLabel}}{{/maxActivity}}<br/>
{{/each}}
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
HPWD
  • 2,232
  • 4
  • 31
  • 61

1 Answers1

0

Okay, so I tried this in my code and it's working great.

{{#each .}} {{#activity}}{{activityLabel}}{{/activity}}<br/> {{#maxActivity}}{{activityLabel}}{{/maxActivity}}<br/> {{/each}}

In a small code sample, this looks odd but in a larger form, it actually makes more sense, visually which might have been my hang up to begin with.

HPWD
  • 2,232
  • 4
  • 31
  • 61