i trying use each using handlebars iterating on 2 objects of type array, when iterate on them individually works fine; when there nesting of both inner object each isn't working.
a = [{a: "a"}, {a: "b"}, {a: "c"}] b = [{b: "x"}, {b: "y"}, {b: "z"}]
now these both objects can iterated fine
{{#each a}} {{this.a}} {{/each}} {{#each b}} {{this.b}} {{/each}}
but wont work
{{#each a}} {{this.a}} //this getting printed {{#each b}} {{this.b}} //this isn't getting printed {{/each}} {{/each}}
(i've not mentioned html syntax reduce confusions )
your problem data context different when within #each
block. within #each
, context current element in iteration, { a: "a" }
, { b: "b" }
, etc. access object of parent context use handlebars paths:
{{#each a}} {{this.a}} {{#each ../b}} {{this.b}} {{/each}} {{/each}}
Comments
Post a Comment