I pass a object context to template A:
data:
{
items: [obj1, obj2, ...],
other: 'str'
}
template:
<template name="A">
<div>
{{#each items}}
{{this.key}}
{{/each}}
</div>
</template>
how to use the other
in each loop ?
I pass a object context to template A:
data:
{
items: [obj1, obj2, ...],
other: 'str'
}
template:
<template name="A">
<div>
{{#each items}}
{{this.key}}
{{/each}}
</div>
</template>
how to use the other
in each loop ?
you can use {{#with}}
var object = {
items: [obj1, obj2, ...],
other: 'str'
}
{{#with object}}
{{#each items}}
{{this.key}}
{{/each}}
{{other}}
{{/with}}
<template name="A">
<div>
{{#each items}}
{{key}}
{{../other}}
{{/each}}
</div>
</template>
Thanks, it’s works ,but the type of data changed, I got a string by ../other
, but other is a Number in object. Why this happened?
Sadly, it;s not works for me.
the …/other should work
but since 1.2 you can do
{{#each item in items}}
{{item.key}}
{{other}}
{{/each}}