我USNG Ember.js 1.0.0 RC1和灰燼數據修訂12無法顯示燼數據
模型我的後背和Ember.js作爲UI PHP修身框架。我想從REST後端加載數據並將其列在模板中。
因此,這裏是我的代碼:
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();
}
});
現在,我嘗試從我的模板商店渲染我的模型:從後端
<script type="text/x-handlebars" data-template-name="ads">
<h1>Ads</h1>
{{#each controller}}
{{title}}
{{/each}}
</script>
響應:
{ads:[{title:"Title" },{ title:"other title" }]}
但商店中沒有顯示任何內容。我的問題是我應該如何在控制器模板中使用控制器中的數據?
Thx for reading!
SOLUTION
我不得不添加各地的JSON響應
{"ads":[{ "title":"Title" },{ "title":"other title" }]}
這是一個棘手的錯誤,因爲控制檯中沒有錯誤消息。非常感謝。在JSON周圍添加引號解決了它! – 2013-07-18 19:38:33