【问题标题】: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')
    

    【讨论】:

      猜你喜欢
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 2016-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-12-04
      相关资源
      最近更新 更多