我到底如何获得组件内部存储的句柄?我正在尝试创建一个从商店返回结果的自动完成组件。
App.AutoCompleteComponent = Ember.Component.extend({
//-------------------------------------------
// Ember Properites
//-------------------------------------------
content: Ember.ArrayController.create(),
//-------------------------------------------
// Instance Properties
//-------------------------------------------
queryText: "",
componentItemSelected: null,
//-------------------------------------------
// Observers
//-------------------------------------------
queryTextChanged: function () {
this.updateContent(this.get("queryText"));
}.observes("queryText"),
//-------------------------------------------
// Instance Methods
//-------------------------------------------
selectItem: function (item) {
this.set("componentItemSelected", item);
},
updateContent: function (queryText) {
if (queryText.length <= 5) {
console.log('not greater than 5 chars');
return;
}
this.get("content").setObjects([]);
var items = App.Company.find();
this.get("content").setObjects(items);
}
});
这是我的公司模型
App.Company = DS.Model.extend({
name: DS.attr('string'),
created_at: DS.attr('date'),
updated_at: DS.attr('date'),
people: DS.hasMany('person')
});
我试过了:
this.get('store')
DS.Store.find('company')
- 只是
store
App.Company.find()
我总是得到一个Uncaught TypeError ... has no method 'find'