mardi 21 novembre 2017

Ember 2.16 Error when creating a state hash in routes/application

Im new to ember coming from react. Inside the routes/application.js I want to use a "state" hash to hold variables outside supporting functions, model(), and actions().

Here is what works:

  session: Ember.inject.service(),
  servers: null,
  clients: null,
  variable3: null,
  variable4: null,
  variable3_id: null,
  selectedDate: null,
  currentUser: Ember.inject.service(),

and this is what I want to do:

state: {
    session: Ember.inject.service(),
    servers: null,
    clients: null,
    variable3: null,
    variable4: null,
    variable3_id: null,
    selectedDate: null,
    currentUser: Ember.inject.service(),
},

When I access it with, say get, get(this, 'state.session') I get this error:

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.

When I dont put the variables in my state hash, and access with get, get(this, 'session') I dont get any issues. What is going on here? Did I provide enough info or am I missing something?

Thanks




Aucun commentaire:

Enregistrer un commentaire