Ember-通知错误无法读取未定义的 属性 "Service"
Ember-notify giving error can't read property "Service" of undefined
我在 ember-cli 项目中使用 ember-notify ember-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'),
行的错误 'cannot read property "service" of undefined' 我已经安装了这个插件并安装了 npm。
@spectras 看起来你的权利至少这仍然是 ember 源的最新版本。
http://builds.emberjs.com/release/ember.js
的第 28242 行
// app/controllers/application.js
export default Ember.Controller.extend({
someService: Ember.inject.service()
});
指出您仍然必须执行此操作,因为注入仅在 Ember 对象上导出
就这样Ember.inject
notify: Ember.inject.service('notify')
我在 ember-cli 项目中使用 ember-notify ember-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'),
行的错误 'cannot read property "service" of undefined' 我已经安装了这个插件并安装了 npm。
@spectras 看起来你的权利至少这仍然是 ember 源的最新版本。
http://builds.emberjs.com/release/ember.js
的第 28242 行// app/controllers/application.js
export default Ember.Controller.extend({
someService: Ember.inject.service()
});
指出您仍然必须执行此操作,因为注入仅在 Ember 对象上导出
就这样Ember.inject
notify: Ember.inject.service('notify')