mardi 1 novembre 2016

EmberJS Formatting hasMany relation

I have the following model setup:

deliveryMethods: DS.hasMany("delivery-method", { async: true })

With this computed property:

  ### COMPUTED PROPERTIES ###
  formattedDeliveryOptions: (->
    @get('deliveryMethods').map((dm) ->
      console.log dm.toJSON()
      return { key: dm.get('name').underscore, value: dm.get('name') }
    )
  ).property("deliveryMethods.@each")

And I am trying to access this property in a controller like so:

  deliveryMethodsArray: (->
    org = @get('controllers.application.currentOrganization')
    console.log org.get('formattedDeliveryOptions')
    return org.get('formattedDeliveryOptions')
  ).property()

But when the console.log dm.toJSON() runs, the organization property is set but nothing else. Not sure what I am doing wrong




Aucun commentaire:

Enregistrer un commentaire