目前正在使用 ember-cli 构建 Ember.js 应用程序。
在reopenClass
模型中,我需要使用 Ember 数据“存储”:
Business.reopenClass({
search: function(params) {
# nope, there is no "store" on the class/static object
var store = this.store;
}
});
我知道我可以使用全局变量,但是全局变量太脏了:
Business.reopenClass({
search: function(params) {
# this works, but the `window` global & `__container__` accessor are verbotten
var store = window.App.__container__.lookup("store:main");
}
});
如何在类/静态函数中使用lookup
或使用?lookupFactory