2016-11-06 88 views
0

HTML METEOR JS。在每个循环的变量

<template name="contact"> 
 
    ... 
 
    {{> FORMULAIRE descrip =descripFormContact }} 
 
    ... 
 
</template> 
 

 
<template name="FORMULAIRE" > 
 
    <form id={{descrip.idForm}} > 
 
    <fieldset id="idFieldSet{{descrip.idForm}}"> 
 
     {{#each descrip.champs}} 
 
     <span id="idSpanLabel{{descrip.idForm}}" ....>{{this.label}}</span> 
 
     ... 
 
     
 
     {{/each}} 
 
    </fieldset> 
 
    </form> 
 
</template>

JS

Template.contact.helpers({ 
 
     descripFormContact: { 
 
      idForm: 'formContact', 
 
      champs: [{ 
 
       nomChp: 'prenom', label: 'Prenom : ', type: 'text', oblig:true, 
 
      }] 
 
     } 
 
})

全部是确定的,但我似乎无法找到“记述的价值。循环“each”中的“idForm”。

有人能告诉我为什么,在循环“每个”,“descrip.idForm”为空,则环路外侧等于“formContact”

谢谢您的回答

YC

+0

试着用''../前缀的表达,以获得外部范围(即'{{../ descrip.idForm}}'。 – MasterAM

+0

的可能的复制[如何访问嵌套循环中的外部{{#each}}集合值](http://stackoverflow.com/questions/13687065/how-to-access-outer-each-collection-value-in-the-nested-loop) – MasterAM

回答

0

您可以在FORMULAIRE模板调用中删除descript和=之间的空格。

个REG,晏