2014-12-19 2 views
0

EmberJs에서 새롭게 변경되었습니다.해머 배열을 만드는 방법

I했습니다이 기능 엠버의 해시의 배열을 만드는 방법

producerTypes: (-> 
    types = @get('model.registrations').mapBy('type').compact().uniq() 
    //Here array of hashes to types and another model call requirements 
).property('model.registrations') 

?

감사합니다 ':

답변

0
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('[email protected]')