问题
i am a newbie in Emberjs.. I am trying to set data content from Emberjs route to controller to display in template..
i followed the suggestions here.. Access content inside a controller function ember
works perfect.. but now i am getting this error
Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed {items: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object], title: current mood}
edit: here is also my code..
http://screencast.com/t/4fXm5n5u9lpH
and here is my template code
http://screencast.com/t/horNlooKx8l
any feedback would be appreciated
thanks
回答1:
Your problem is that https://torid-heat-7210.firebaseio.com/fixed_column.json returns an Object ({}
) where as {{#each}}
helper is expecting an array ([]
).
You can modify your setupController
method as follows to get it to work:
setupController: function(controller){
Ember.$.ajax({
url: 'https://torid-heat-7210.firebaseio.com/fixed_column.json',
type: 'GET'
}).done(function(data){
controller.set('content', data.items);
})
}
Working solution here
来源:https://stackoverflow.com/questions/28680572/setting-data-from-route-to-controller-error-in-emberjs