Friday, September 11, 2015

more handlebars 101

Before I mentioned some handlebars 101 and specifically looping...  it turns out that all your variables inside a handlebars loops are local to the item you're 'on' at that point in the iteration, but if you want you can access the parent context via "../", e.g.

<th>{{surveyname}}</th>     
 {{#each survey.options}}
   <th><h1><img src="surveys/{{../surveyname}}/images/{{this.img}}"></h1> </th>
 {{/each}}


so without the ../ inside the loop,  there wouldn't be access to surveyname...  (these seems a lot more elegant than Angular 1.x's way of handling child scoping issues)

No comments:

Post a Comment