I'm trying to have specific instructions running when my data coming from the server via Ember data is fully loaded. I want to redirect the ember app to a different route following the number of items the server returned. I have tried to use the promise returned by the findAll()
method, but the function gets fired too soon as the data has not been loaded yet. Then I tried to use the event didLoad
but it never gets fired. Has anyone any thoughts for this ? Thanks !
The records should be available by the time the promise is resolved if you are following the pattern below. Additionally the afterModel hook in a route will have the model resolved. Now this is a little different if you have async relationships or some other structure, if that's the case you need to specify more information.
var blah = this.get('store').find('apples');
blah.then(function(records){
//records are loaded at this point.
console.log("Loaded " + records.get('length') + " records");
});
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.