Ember: access controller property in loop


#1

I have template as follows:

  {{#each imageIds}}
    {{image-tag this height=50 width=50}}
    {{favourite-star this favourite isNew=true}}
  {{/each}}

in controller, i have imageIds array of public-ids which are string values

for ex [“1406708695/bco89eofwk6cuw8jjgwl.jpg”,“1406710104/knlyudtvrxue0j36xnuw.jpg”]

and favourite is my controller property, whose value is simple string.

So how i can access my controller property favourite inside the each loop, as inside loop the context is string value… and not the controller…

Pls help me to fix it.

Thanks.


#2

its easy… just access it as controller.favourite

http://gregbabiars.com/blog/2013/11/28/understanding-this-scoping-in-ember-handlebars-each-blocks/