到目前为止,我Ember.js
按照项目的结构和代码开发了我的@trek github
项目,它使用grunt-neuter
依赖项将所有内容粘合在一起。
我创建了许多util
我的应用程序需要的类,都在App.
命名空间内,一切都按预期工作:)
现在,我想从 Stefan Penners 开始ember-app-kit
,我在实现自己的util
类时遇到了问题......例如,我无法util
两次获取一个类:
import AuthenticationManager from 'myapp/utils/authentication/manager';
import Ajax from 'myapp/utils/ajax';
var App = Ember.Application.extend({
modulePrefix: 'myapp'
});
Ember.Application.initializer({
name: 'setup_1',
initialize: function (container, application) {
Ajax.setup(someSecurityRelatedValues);
AuthenticationManager.setup({
someProperty: ''
});
}
});
export default App;
import Ajax from 'myapp/utils/ajax';
var AuthenticationManager = Ember.Object.create({
setup: function (someProperty) {
// do something very important
Ajax.get('ajax/path/to/server', {data: someData}).then(function (data) { // <-- Ajax is always "undefined"!
// more important stuff to do ;)
}));
}
});
export default AuthenticationManager;
不知何故,可以在上下文中获取Ajax
依赖Ember.Application.initializer
关系,但在AuthenticationManager
上下文中,Ajax
依赖关系始终undefined
存在,并且没有给出进一步的错误/消息......
我在这里做错了什么?