Ember model.get () does not return value or template binding properly

I have a route that populates a model property using the .store.query() method inside the RSVP hash:

 model(params, transition) { return Ember.RSVP.hash({ myData: this.store.query('table-datum', parameters) }); } 

This returns a promise and seems to receive data to my store according to inspector Ember, I see the correct number of rows, and they all have attributes with the data filled in.

Then I have a simple component template inside my main view template with each block to output the output:

  {{#each data as |result|}} <tr> <td>{{result.prop1}}</td> <td>{{result.prop2}}</td> </tr> {{/each}} 

I pass the property to my component as follows:

  <div id="tableContainer"> {{result-table data=model.myData}} </div> 

But for some reason, the template binds the correct number of lines, but gets access to the bits prop1 and prop2 class prop2 (so I just get 20 lines of empty lines)

If I try to output only {{result}} in my template, it looks like this:

 < client@model :table-datum::ember574:1> 

I am sure that the data is there somewhere only, it seems that my template does not have access to properties for some reason.

Any ideas on where to look for this?

EDIT: Recording the result object looks almost correct, but not quite:

enter image description here

The extension of the internal model shows some data, but also says "Empty object", which seems wrong to me!

enter image description here

EDIT: if that helps, I have a controller function that gets model.myData and works on it, which gives me the result I expect:

 getMax() { let max = _.max(this.get('model.myData'),'aField').aField; console.log(max); // logs 41 as I expect return max; } 
+5
source share
1 answer

Is this what you do in your route model?

 model() { return Ember.RSVP.hash({ myData: this.store.query('table-datum', parameters) }).then(function(results) { return results; }).catch(function(error) { throw error; }); }, setupController(controller, model) { this._super(...arguments); Ember.set(controller, 'myData', model.myData); } 

Then in the template I would get access to myData.

0
source

All Articles