3

到目前为止,我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存在,并且没有给出进一步的错误/消息......

我在这里做错了什么?

4

0 回答 0