2015-11-24 44 views
2

我在我的ember-cli項目中使用了ember-notify ember-notifyEmber-notify給出錯誤無法讀取未定義的屬性「服務」

import { 
    Component, 
    inject 
} from 'ember'; 
export default Component.extend({ 
    notify: inject.service('notify'), 
    actions: { 
    sayHello() { 
     this.get('notify').info('Hello there!'); 
    } 
    } 
}); 

我剛剛從文檔中複製了相同的示例代碼。但我得到錯誤「無法讀取屬性」服務「的線路notify: inject.service('notify'),未定義'我已經安裝了這個插件,並做了一個npm安裝。

+0

您是否在安裝插件後重新啓動服務器? –

+1

我不知道'inject'是否可以直接導入。你可以嘗試明確地解決這個問題:'從'ember'導入Ember;'並使用'Ember.inject.service('notify')'。 – spectras

回答

0

上的

只是做Ember.inject

notify: Ember.inject.service('notify') 
0

@spectras看起來像你的權利atleast這仍然是最新版本的燼源。線#28242 http://builds.emberjs.com/release/ember.js

// app/controllers/application.js 
export default Ember.Controller.extend({ 
    someService: Ember.inject.service() 
}); 

指向的事實,你應該還是有這樣做,因爲注射時只出口灰燼對象

相關問題