title: EmberJS calling controller function within #each
body: <p>I'm trying to call a controller function inside a #each template to check if the model is selected. This needs to receive the model for each loop iteration.</p>
  
  <p>jsbin is here <a href="http://emberjs.jsbin.com/bemos/4/edit" rel="nofollow">http://emberjs.jsbin.com/bemos/4/edit</a></p>
  
  <p>I've tried using the following template, but adding a parameter to {{controller.selected}} results in ember throwing an exception, or not doing anything (the result seems to be different in jsbin).</p>
  
  <pre><code>{{#each model}}
      &lt;li&gt;&lt;a hres="#" {{action "clickItem" this}}&gt;{{label}} -- selected is {{controller.selected name}} &lt;/a&gt;&lt;/li&gt;
  {{/each}}
  </code></pre>
  
  <p>My function in the controller looks as follows</p>
  
  <pre><code>selected: function(id) {
      var list = this.get("selectedList");
      console.log("Checking sel for", id);
      if(list.contains(id))
          return true;
      return false;
  }.property("selectedList")
  </code></pre>
  
  <p>In the jsbin, I expect to be able to click on the "Hello 1"/"Hello 2" elements, and this should change the part of the text that says "selected is false" to true. It should also update the number of items selected in the bottom. Currently, this shows 1 item is selected (since the default is selectedList:["2"]) however "Hello 2" says "selected is false" - this should say "true".</p>
  
  <p>(I should add I'm pretty new to EmberJS as have been working with ExtJS for a few years!).
  Thanks</p>