我刚从react来到ember。路由/应用程序内部。我想使用“state”散列来保存支持函数、model()和actions()之外的变量。
以下是有效的方法:
session: Ember.inject.service(),
servers: null,
clients: null,
variable3: null,
variable4: null,
variable3_id: null,
selectedDate: null,
currentUser: Ember.inject.service(),
这就是我想做的:
state: {
session: Ember.inject.service(),
servers: null,
clients: null,
variable3: null,
variable4: null,
variable3_id: null,
selectedDate: null,
currentUser: Ember.inject.service(),
},
当我访问它时,比如说get,
get(this, 'state.session')
我发现这个错误:
ember.debug.js:29034 Error while processing route: analytics Assertion Failed: Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container. Error: Assertion Failed: Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.
当我没有把变量放入
state
散列,并使用get访问,
get(this, 'session')
我没有任何问题。这是怎么回事?我提供了足够的信息还是遗漏了什么?
谢谢