title: Change class with ng-click in AngularJS
body: <p>I need two buttons of a kind that can change the class of an element. Each button represent a different class.</p>
  
  <p>I try to pass $index in the ng-click but it seems to not be working correctly.. Any suggestions would be much appreciated! :-)</p>
  
  <p>Some styling</p>
  
  <pre><code>&lt;style&gt;
  .class1 {color: red;}
  .class2 {color: green;}
  &lt;/style&gt;
  </code></pre>
  
  <p>The view</p>
  
  <pre><code>    &lt;div ng-model="myClasses"&gt;
  
      &lt;a href="#" ng-click="itemClick($index)"&gt;1'eren&lt;/a&gt;
      &lt;a href="#" ng-click="itemClick($index)"&gt;2'eren&lt;/a&gt;
      &lt;p class="{{myClasses}}"&gt;Torben {{myClasses}}&lt;/p&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>And my Angular</p>
  
  <pre><code>&lt;script&gt;
      var app = angular.module('plunker', []);
  
      app.controller('MainCtrl', function($scope) {
        $scope.myClasses = "class0";
  
  
        $scope.itemClick = function ($index){
          if ($index == 1){
            $scope.myClasses = "class1";
          } else if ($index == 2) {
            $scope.myClasses = "class2";
          } else {
            $scope.myClasses = "class1";
          }
        };
      });
    &lt;/script&gt;
  </code></pre>
  
  <p><a href="http://plnkr.co/edit/boQa228Aiohx7QdvjeTP?p=preview" rel="nofollow">A plunker</a></p>