2015-04-01 54 views
0

我在Ember.js以下型號:Ember.js /訪問中的每個父陣列 - 嵌套每個

App.Fraction.FIXTURES = [ 
    { 
     id   : 200, 
     title  : "General", 
     list  : 100, 
     provider : [400], 

     attributes : [800,801] 
    }, { 
     id   : 201, 
     title  : "Kinder Preise", 
     list  : 100, 
     provider : [400] 
    } 
]; 

每種級分具有提供商和屬性,並且每個提供者具有服務。我想爲每個提供商創建一個表,其中provider.services爲行,attributes爲色彩。

在我的模板我嘗試這樣做:

{{#each provider}} 
    <h3>{{title}}</h3> 
    <hr /> 

    <table> 
     <thead> 
      <tr> 
      {{#each ../attributes}} 
       <th> {{title}} nothing happend!!!</th> 
      {{/each}} 
      </tr> 
     </thead> 

     <tbody> 
      {{#each services}} 
       <tr> 
       <td> {{title }}</td> 
       {{#each attributes}} 
        <td>{{value}}</td> 
       {{/each}} 
       </tr> 
      {{/each}} 
     </tbody> 
     </table> 
    {{/each}} 

好像路徑標識符「物件」並不在這裏工作。有沒有解決方法?

回答

0

在灰燼本的最新版本是,你會怎麼做:

{{#each providers as |provider|}} 
    <h3>{{provider.title}}</h3> 
    <hr /> 

    <table> 
     <thead> 
      <tr> 
      {{#each attributes as |attr|}} 
       <th> {{provider.title}} should work</th> 
      {{/each}} 
      </tr> 
     </thead> 
    </table> 
{{/each}} 
+0

是的,這裏有一個不錯的博客摘錄:http://emberjs.com/blog/2015/02/07/ember -1-10-0-released.html#toc_block-PARAMS – 2015-04-02 09:22:59