Reputation: 423
i get is this object on my view :
[
{
"2016": [
{
"model": "R8",
"variant": "R8 s TRONIC"
}
],
"2017": [
{
"model": "A5",
"variant": "A5 SPORTBACK"
}]
} ]
this is in my object pageContent
i want to access only the name of the field i i want to get only the 2016, 2017
i tried to use this
{{#each pageContent as |item| }}
{{item}}
{{/each}}
i found a way to do this but i have many item not only the .0
{{#each pageContent as |item| }}
{{item.2017.0.model}}
{{/each}}
thats how i push it:
if (item.RegYear in result[0]) {
result[0][item.RegYear].push({
model: item.Model,
variant: item.Variant
});
}
so i want to know how i access the name of the field , model and variant i have
Upvotes: 0
Views: 539
Reputation: 423
so i found the solution finally :
{{#each pageContent as |item|}}
<pre>
{{#each item as |obj|}}
{{#unless @last}}
{{@key}}
{{#each obj}}
{{this.variant}}
{{/each}}
{{/unless}}
{{/each}}
</pre>
{{/each}}
Upvotes: 0
Reputation: 20206
You can get key from your object like this,
{{#each pageContent}}
{{@key}}: {{this}}
{{/each}}
Upvotes: 1