I’m relatively new to Ember, and I’m trying to get my head around the correct Ember way of manipulating data pulled in via an AJAX call before setting it as the model (so it can be used in the template).
The short version is the JSON is an object full of objects. I (think I) need it to be an array of objects so I can loop through the array in the template and build a <select> list.
Initially my thinking was to do something like this in the route:
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return Ember.$.getJSON('/json/data.json', function(data) {
let arr = [];
Ember.$.each(data, function(index, value) {
arr.push(value);
})
return arr;
});
}
});
But when I {{log model}} in the template, I still have the original object. Which in hindsight, I think makes sense.
Any suggestions on how I can achieve what I’m after?