Injecting dependencies into an Ember model

前端 未结 1 628
再見小時候
再見小時候 2021-01-23 05:31

I\'m attempting to inject dependencies into my Ember models.

https://github.com/emberjs/ember.js/issues/3670, states that this is disabled. Following a link to https://g

相关标签:
1条回答
  • 2021-01-23 05:37

    Model injections does indeed work:

    Ember.MODEL_FACTORY_INJECTIONS = true;    
    App = Ember.Application.create();
    
    App.initializer({
      name: 'model-injection',
    
      initialize: function(container, application) {
    
        var cfg = {version: '1'};
        container.register('app:config', cfg, {instantiate: false});
    
    
        container.injection('model', 'cfg', 'app:config');
        App.advanceReadiness();
      }
    });
    
    App.deferReadiness();
    

    http://emberjs.jsbin.com/lomiy/1/edit

    0 讨论(0)
提交回复
热议问题