ember.js - How to traverse through hasMany relationship in console? -


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' 

i can both cardproperty , cardcategory via app.xxx.find() / find(n) can't traverse through relationship in chrome console.

this:

app.cardcategory.find(1).get('properties').objectat(1) 

returns `undefined' whereas:

app.cardcategory.find(1).get('properties') 

returns:

class {type: undefined, store: class, _changestosync: ember.orderedset, owner: class, name: "properties"…} 

i had problems getting data in console i'd know definitive way this.


update

in response comment.

app.cardcategory.find(1).get('properties.length') returns0. response to/card_categories/1` following:

{   "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"   } } 

some quick details, hasmany , belongsto aren't materialized after find.

try couple of things see if case.

app.cardproperty.find(); // load properties first var cc = app.cardcategory.find(1); var props = cc.get('properties'); propslength = props.get('length'); props.foreach(function(prop){    console.log('prop exists here: ' + prop.get('label')); } 

if case, can

ember.run.next({    // materialized @ point }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -