I am usng Ember.js 1.0.0 RC1 and ember-data revision 12
I have PHP Slim framework in the back and Ember.js as UI. I want to load data from REST backend and list it in the template.
So here is my code:
window.App = Ember.Application.create();
// Store
App.Store = DS.Store.extend({
revision: 12,
});
// Adaper
DS.RESTAdapter.reopen({
url: '/slim'
});
// Router
App.Router = Ember.Router.extend();
App.Router.map(function(){
this.route('ads', {path: '/ads'});
});
// Ad model
App.Ad = DS.Model.extend({
title: DS.attr('string')
});
// AdsRoute
App.AdsRoute = Ember.Route.extend({
model: function(){
return App.Ad.find();
}
});
Now I try to render my models from the store in my template:
<script type="text/x-handlebars" data-template-name="ads">
<h1>Ads</h1>
{{#each controller}}
{{title}}
{{/each}}
</script>
Response from backend:
{ads:[{title:"Title" },{ title:"other title" }]}
But nothing from the store is displayed. My question is how should I use data from controller in my handlebars template?
Thx for reading!
SOLUTION
I had to add quotes around JSON response
{"ads":[{ "title":"Title" },{ "title":"other title" }]}