Reputation: 2361
I have posted my code here.
Here i am getting data of first node of home_products
i.e.
"contents": [
{
"id": "1",
"product_name": "abc11"
},
{
"id": "2",
"product_name": "abc12"
}
]
Failed to get data of second node i.e.
"contents": [
{
"id": "1",
"product_name": "abc21"
},
{
"id": "2",
"product_name": "abc22"
}
]
every time i am getting same data i.e. data of first node.
Can any one help me to solve this issue?
Upvotes: 1
Views: 104
Reputation: 23322
Your FIXTURES
are wrongly nested, you should only have one contents
array, resulting in:
Astcart.Application.FIXTURES=[
{
"home_products": [
{
"id": "1",
"name": "Mobiles & Accessories",
"contents": [
{
"id": "1",
"product_name": "abc11"
},
{
"id": "2",
"product_name": "abc12"
},
{
"id": "3",
"product_name": "abc21"
},
{
"id": "4",
"product_name": "abc22"
},
{
"id": "5",
"product_name": "abc31"
},
{
"id": "6",
"product_name": "abc32"
}
]
}
]
}
];
Hope it helps.
It seams that the nested contents
arrays inside each home_product
need different id
's although they are in isolated arrays otherwise they get treated as one and overridden:
Astcart.Application.FIXTURES = [
{
"id": "1",
"name": "Application 1",
"home_products": [
{
"id": "1",
"name": "Mobiles & Accessories",
"contents": [
{
"id": "1",
"product_name": "abc11"
},
{
"id": "2",
"product_name": "abc12"
},
{
"id": "3",
"product_name": "abc21"
},
{
"id": "4",
"product_name": "abc22"
},
{
"id": "5",
"product_name": "abc31"
},
{
"id": "6",
"product_name": "abc32"
}
]
},
{
"id": "2",
"name": "Bags & Cases",
"contents": [
{
"id": "7",
"product_name": "def11"
},
{
"id": "8",
"product_name": "def12"
},
{
"id": "9",
"product_name": "def21"
},
{
"id": "10",
"product_name": "def22"
},
{
"id": "11",
"product_name": "def31"
},
{
"id": "12",
"product_name": "def32"
}
]
}
]
}
];
<script type="text/x-handlebars" data-template-name="index">
<ol>
{{#each application in model}}
<li>{{application.name}}</li>
<ul>
{{#each homeproduct in application.home_products}}
<li>{{homeproduct.name}}</li>
<ul>
{{#each item in homeproduct.contents}}
<li>{{item.product_name}}</li>
{{/each}}
</ul>
{{/each}}
</ul>
{{/each}}
</ol>
</script>
Upvotes: 1