【问题标题】:How make in ember array of hashes如何在 ember 中生成哈希数组
【发布时间】:2015-02-18 15:15:15
【问题描述】:
我是 EmberJs 的新手。
我有这个功能,
producerTypes: ( ->
types = @get('model.registrations').mapBy('type').compact().uniq()
//Here array of hashes to types and another model call requirements
).property('model.registrations')
如何在 ember 中制作哈希数组?
谢谢' :)
【问题讨论】:
标签:
ruby-on-rails
ember.js
coffeescript
【解决方案1】:
producerRequirements: ( ->
documentation = []
types = @get('model.registrationsDocumentations').
mapBy('producerType').compact().uniq() //first map by type
for producerType in types
requirements = @get('model.registrationsDocumentations').
filterBy('producerType', producerType) //second filter by producerType
documentation.addObject( //add to the array
producerType: producerType,
requirements: requirements
)
documentation
).property('model.registrationsDocumentations.@each')