2014-04-14 13 views
0

안녕하세요 나는 collectionView에 대해 더 복잡한 배열을 사용할 수 있는지 알고 싶습니다.배열의 Emberjs CollectionView 배열

App.GroupList = Ember.ArrayController.create({ 
    content: ['A','B','C','D'], 
}) 

App.GroupListView = Ember.CollectionView.extend({ 
    tagName: 'tbody', 
    contentBinding: "App.GroupList" 
}) 

을 그리고이처럼 표시 :

지금 난 단지 이런 식으로 사용하고 있기 때문에

<table class="table-history"> 
    {{#collection App.GroupListView}} 
    <td class="col-left"> 
     {{view.content}} 
    </td> 
    <td> 
     <span class="col-number-contact">0</td> 
    </td> 
    <td> 
     <div class="ph-img"></div> 
    </td> 
    <td> 
     <div class="ed-img"></div> 
    </td> 
    {{/collection}} 
</table> 

지금까지 너무 좋아, 그 잘 작동하지만, 내가 좋아하는 것 다음과 같이 콘텐츠 내부에 자세한 정보를 추가하십시오 :

content: [ 
    ['A','1'], 
    ['B','2'], 
    ['C','3'], 
] 

<td> tad (내부가 0 인 tad). 하지만 작동하지 않습니다 ... 그리고 나는 심지어 내 템플릿에 그들을 표시하는 방법을 모르겠다.

누군가 이미 복잡한 컬렉션 콘텐츠를 처리 했습니까?

답변

2

이 같은 대신 객체의 배열을 사용할 수 있습니다

App.GroupList = Ember.ArrayController.create({ 
    content: [{'id':1,val:'A'},{'id':2,val:'B'},{'id':3,val:'C'},{'id':4,val:'D'}]; 
}); 

그런 다음 템플릿에,이처럼 액세스 할 수 있습니다

<table class="table-history"> 
    {{#collection App.GroupListView}} 
    <td class="col-left"> 
     {{view.content.val}} 
    </td> 
    <td> 
     <span class="col-number-contact">{{view.content.id}}</td> 
    </td> 
    <td> 
     <div class="ph-img"></div> 
    </td> 
    <td> 
     <div class="ed-img"></div> 
    </td> 
    {{/collection}} 
</table> 
+0

을 내가 찾던 정확히 무엇을 그! 고맙습니다! – SuperMarco