App.CardCategory = DS.Model.extend
properties: DS.hasMany 'App.CardProperty'
App.CardProperty = DS.Model.extend
symbol: DS.attr 'string'
label: DS.attr 'string'
popover: DS.attr 'string'
unit: DS.attr 'string'
DS.RESTAdapter.configure 'plurals',
card_property: 'card_properties'
我可以通过 App.XXX.find() / find(n) 获得两者CardProperty
,CardCategory
但无法在 Chrome 控制台中遍历这种关系。
这个:
App.CardCategory.find(1).get('properties').objectAt(1)
返回“未定义”,而:
App.CardCategory.find(1).get('properties')
返回:
Class {type: undefined, store: Class, _changesToSync: Ember.OrderedSet, owner: Class, name: "properties"…}
我总是在控制台中获取数据时遇到问题,所以我想知道这样做的最终方法是什么。
更新
回应评论。
App.CardCategory.find(1).get('properties.length') returns
0 . The response to
/card_categories/1`如下:
{
"card_category":{
"contains_new_purchase_slider":false,
"id":1,
"name":"Balance Transfer Cards",
"promo_card_id":3,
"promo_panel_active":true,
"promo_panel_card_teaser":"Maiores rerum quibusdam consectetur id culpa. Enim unde explicabo et quae",
"promo_panel_description":"Fugiat optio sint dolores non ut qui eveniet.",
"promo_panel_header":"Unde ut voluptates eos ea dolor rerum mollitia.",
"property_ids":[
4,
2,
5,
16
],
"slug":"balance-transfer-cards"
}
}