简体   繁体   中英

ember store is undefined

Here are the main code lines of my ember application :

/** Initialization and configuration */
App = Ember.Application.create({
    LOG_TRANSITIONS: true
});
App.ApplicationStore = DS.Store.extend();
App.ApplicationAdapter = DS.FixtureAdapter.extend();

and :

App.GenerationController = Ember.Controller.extend({
actions: {
    generation: function(){
        var graph = this.store.find('graph', 1);
        [...]
    }
}

When my action is launched, I have this in my console : TypeError: this.store is undefined

Can someone help me to fix it ? And moreover, to understand why the store seems not accessible from a controller ?

Thanks

In older versions of Ember the store was available only as a computed property, so it had to be accessed as such:

this.get('store') // set and get handle asynchrony for us

Now, the store is setup as a service during app initialization. This guarantees that the store is already setup by the time your app logic begins executing and allows you to do:

this.store

So, you are using an old Ember version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM