title: How can I pass a parameter to an ng-click function?
body: <p>I have a function in my controller that looks like the following:</p>
  
  <p>AngularJS:</p>
  
  <pre><code>$scope.toggleClass = function(class){
      $scope.class = !$scope.class;
  }
  </code></pre>
  
  <p>I want to keep it general by passing the name of the class that I want to toggle:</p>
  
  <pre><code>&lt;div class="myClass"&gt;stuff&lt;/div&gt;
  &lt;div ng-click="toggleClass(myClass)"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>But <code>myClass</code> is not being passed to the angular function. How can I get this to work? The above code works if I write it like this:</p>
  
  <pre><code>$scope.toggleClass = function(){
      $scope.myClass = !$scope.myClass;
  }
  </code></pre>
  
  <p>But, this is obviously not general. I don't want to hard-code in the class named <code>myClass</code>.</p>