从服务器上返回的我的 JSON 对象看起来像这个 :
[
{
"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]
}
}
]}
]
我的JJ看起来像这个
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));
});
});
}
});
我的问题是,我如何在 showaliassonsportid 阵列上行动, 甚至如何访问它来显示别名. name, 而不是类型. name value? 我读过, 我可能需要从别名和或 showaliassonsportid 阵列中创建一个对象, 但我对如何用 Ember 来做到这一点感到困惑 。