Wednesday, 7 August 2013

EmberJs - Getting json data to the view

EmberJs - Getting json data to the view

This will be something extremely simple but at the moment I am having
trouble working out how to get my json data into a my view template.
For my index page I have the following code:
App.IndexRoute = Ember.Route.extend({
model: function() {
var pageContent = App.Content.find(1);
}
});
Which is returning the JSON I need for the page content with the ID of 1.
(This works as I see the results in firebug console.
It's returning the following json
{"content":[{"id":"1","name":"Home","extended":"This is the
homepage.","created":"2013-08-05 23:40:55","modified":"2013-08-05
23:40:55"}]}
I have this view setup but I cannot work how how to get the data from json
to the view:
<script type="text/x-handlebars" id="index">
<div class='index'>
{{pageContent.entended}}
The home page
</div>
P.s. I only just started with EmberJS so I assume this will be extremely
simple.
Thanks

No comments:

Post a Comment