Iterating over Ember.js ember-data Record Arrays

后端 未结 1 681
后悔当初
后悔当初 2021-02-15 16:29

I\'ve been beating my head against this problem all day, and I feel like I\'m close to a solution but just can\'t quite make it happen. I\'m using Ember.js with Ember-Data and

相关标签:
1条回答
  • 2021-02-15 17:06

    It appears like you're accessing the models before they are finished loading (You can see this in the property, isUpdating). If you feel like lazily looking at this you can use ember run later to just see the items a wee bit later. Or you can set the model on the controller and render it and let ember update the view when the models are finished loading...

     Ember.run.later(function(){
        data.forEach(function(item){
        console.log(item);
       });
     }, 2000);
    
    
    
     App.ApplicationRoute = Ember.Route.extend({
       activate: function(){
         this.controllerFor('supervisors').set("model", App.Supervisor.find());
       }
     });
    

    http://jsbin.com/ijiqeq/12/edit

    Good luck with Ember!

     someArray: function(){
       var arr = Ember.A();
       this.get('model').forEach(function(item){
         item.get('sites').forEach(function(site){
           arr.pushObject(someObject); //some object that is represents each specific combination
         });
       });
     }.property('model')
    
    0 讨论(0)
提交回复
热议问题