I try to access the contents of my model in the appropriate controller, but first it returns a promise with undefined attributes, and then when it refers to the second or third time it returns a value.
Could there be a delay in receiving data from the REST adapter?
Also the attempt to use '.then ()' in the request in the controller does not work, since I believe that it is used only in the route.
App.EquipmentsController = Ember.ArrayController.extend({
getContentForMapping: function() {
console.log(this.get('model').objectAt(1).get('contractor.name'));
}
});
It is strange that when I access the properties of a model from a template view in a loop, it immediately returns them.
{{#each equipment in model}}
<p>{{equipment.contractor.name}}</p>
{{/each}}
The following describes how I set up the route. It captures a list of equipment related to a particular site:
App.EquipmentsRoute = Ember.Route.extend({
model: function(){
return this.modelFor('site').get('equipment');
},
setupController: function(controller, model) {
controller.set('model', model);
}
});
source
share