My JSON object that is returned from the server looks like this:
[
{
"id" : 1,
"name": "Biking",
"type": [{
"id" : 1,
"name" : "Road"
}]
},
{
"id" : 2,
"name": "MotorCycling",
"type": [{
"id" : 1,
"name" : "MX",
"alias" : {
"name": "Dirt",
"showaliasonsportid": [1,2,3]
}
}
]}
]
My ember js looks like this
App.Activity = Em.Object.extend({
});
App.ActivityListView = Em.View.extend({
});
App.activitiesController = Em.ArrayProxy.create({
content: [],
loadActivities: function () {
var self = this;
$.getJSON('data/activities.json', function(data) {
data.forEach(function(item) {
self.pushObject(App.Activity.create(item));
});
});
}
});
My question is how can I act on the showaliasonsportid array or even access it to display the alias.name instead of the type.name value? I have read that I may need to create an object out of the alias and or showaliasonsportid array but I am confused on how to do this with Ember.
Check out Ember Data, it solves these sort of problems very well: https://github.com/emberjs/data