学习Ember.js + Ember-data。我在http://locahost:3000
var App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 11,
url:"http://localhost:3000"
});
App.Client = DS.Model.extend({
shortName: DS.attr('string'),
longName: DS.attr('string')
});
var clients = this.store.find('client');
console.log(clients);
使用最终的Ember.js 1.0和Ember-data 1.0.0 beta2。得到错误
未捕获的TypeError:无法调用未定义的方法'find'
想知道是否有关于ember-data的更新教程。本教程:http://twbrandt.github.io/2013/02/22/Ember-Data-Quick-Start-Guide/已过时。
答案 0 :(得分:0)
您需要在某些路线中使用this.store
。例如:
var App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 11,
url:"http://localhost:3000"
});
App.Client = DS.Model.extend({
shortName: DS.attr('string'),
longName: DS.attr('string')
});
App.IndexRoute = Ember.Route.extend({
model: function() {
this.store.find('client').then(function(clients) {
console.log(clients);
});
}
});