mercredi 28 janvier 2015

Get data from ember data bind it to a widget in view

I have a router that returns data from the data model, I want to use this data to bind it to a widget in a view.


model:



myApp.Unit = DS.Model.extend({
active: DS.attr('boolean'),
allowdecimals: DS.attr('boolean'),
name: DS.attr('string'),
count: DS.attr('number'),
});


Router:



myApp.EunitsRoute = Ember.Route.extend({
model: function() {
return this.store.find('unit');
},
setupController: function(controller, model) {
this._super(controller, model);
controller.set('units', model);
},
actions: { ...


In the view I expect an object formated as follows:



[ {"id": 1,"active": true,"allowdecimals": true,"name": "Pint","count": 8}, {"id": 2,"active": true,"allowdecimals": true,"name": "Each","count": 8}, ...]


what I am getting now in the view is an object:<DS.RecordArray:ember400>





Aucun commentaire:

Enregistrer un commentaire