title: Ember 2 Actions Inside Each Loop
body: <p>Consider the following:</p>
  
  <pre><code>days_week: [
      {
          selected '',
          day: 'mon'
      },
      {
          selected '',
          day: 'wed'
      },
      {
          selected '',
          day: 'fri'
      }
  ]
  </code></pre>
  
  <p>Inside my template, I can loop through the days:</p>
  
  <pre><code>{{#each days_week as |day_week index|}}
      {{day_week.day}}
  {{/each}}
  </code></pre>
  
  <p>Which produces this:
  <strong>mon
  wed
  fri</strong></p>
  
  <p>What I now want to do is assign an action, so that upon click it will add a class, and upon clicking again, it will remove the class....</p>
  
  <pre><code>{{#each days_week as |day_week index|}}
      &lt;button class="{{day_week.selected}}" {{action 'toggle' day_week}}&gt;
          {{day_week.day}}
      &lt;/button&gt;
  {{/each}}
  </code></pre>
  
  <p>However, the following code does not seem to work to (start by adding the class <em>highlight</em>)?</p>
  
  <pre><code>actions: {
      toggle: function(day_week){
          day_week.set('selected','highlight');
      }
  }
  </code></pre>
  
  <p>and I get this error: <strong>TypeError: day_week.set is not a function</strong> ?</p>