title: Angular: What is a best practice for changing a single div's class when multiple divs have the same class?
body: <p>I'm fairly new to angular.  What I'd like to to is replace the class of a div when a button is clicked.  Using "ng-class" changes the class of all the divs with that class on the page, where I'd like to just select one to replace.</p>
  
  <p>This <a href="http://jsfiddle.net/gstipton/XxMSm/25/" rel="nofollow">jsfiddle</a> demonstrates what I'm trying to do.  I'm attempting to use jQuery, but as you can see it's not working in this context.  My guess is there is a more "angular-ish" way to do it.  Any suggestions?</p>
  
  <p>Here is the code in the jsfiddle:</p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
  &lt;div class="test1"&gt;
      Text1
  &lt;/div&gt;
  &lt;div class="test1"&gt;
      Text2
  &lt;/div&gt;
  &lt;button ng-click="click($event)"&gt;Click&lt;/button&gt;
  &lt;/div&gt;
  
  var myApp = angular.module('myApp', []);
  
  function MyCtrl($scope) {
  
     $scope.click = function (e) {
         var source = e.target || e.srcElement;
         var div = source.prev("div.test1:first");
         div.toggleClass('test1');
     };
  }
  
  .test1 {
    color: blue;
  }
  </code></pre>