I have created FIXTURES
using ember-model
and I am trying to access it on template, but it is not showing any result if I use {{model.name}}
. It is working fine with each
helper.
I want to access single node of model like {{model.name}}
without using any each
helper.
My model code:
Astcart.Home.FIXTURES=[
{
"id": "1",
"logo_url": "img/logo.jpg",
"name": "gau",
"list": [
{
"id": "1",
"name": "amit"
},
{
"id": "2",
"name": "amit1"
}
]
}
];
My router code :
Astcart.HomeRoute = Ember.Route.extend({
model: function() {
return Astcart.Home.find();
}
});
My template :
<script type="text/x-handlebars" data-template-name="home">
{{model.name}}
<ul>
{{#each item in model}}
<img {{bindAttr src="item.logo_url"}}></img>
<li>{{item.name}}</li>
{{#each item in item.list}}
<li>{{item.name}}</li>
{{/each}}
{{/each}}
</ul>
</script>
I have updated my code here