Reputation: 2589
there are some data:
var data = [ {id:"a",b:[{name:"1",value:"a"},{name:"2",value:"x"}],c:"a"} {id:"b",b:[{name:"2",value:"b"},{name:"3",value:"c"}],c:"b"} ]
and in the Template
... {{#each data}} {{id}} select> {{#each b}} option {{#if equal value c}} selected {{/if}} > name option> {{/each}} {{/each}} ..
The function:
Template.temp.equal = function(value,test){ console.log(value); console.log(test); }
and the "test" is undefined,In other words,In the second #each can't read the value of the First #each . What's the step I have forgotten? how can I get the value of property "c" in second #each ?
Upvotes: 0
Views: 94
Reputation: 298
U can do it with registerHelper;
Handlebars.registerHelper("equal",function(value,test,options) {
if(value==c)
return options.fn(this);
return options.inverse(this);
});
And your template
{{#equal value c}}
selected
{{/equal}}
Upvotes: 0