title: Passing function with parameters in ng-class to get the class
body: <p>I am trying to use ng-class of angular. I have a function which returns the class based on the parameters we send it. How can i achieve it ? </p>
  
  <p>Here's what i tried:</p>
  
  <pre><code>&lt;div ng-class="{ getClass(key) }" &gt;
  </code></pre>
  
  <p>and in the controller: </p>
  
  <pre><code>getClass = function(keyVal){
      angular.forEach(myArray, function(value, id){
          if(value.key === keyVal){
              console.log(value.class);
              return value.class;
          }
      });
  }
  </code></pre>
  
  <p>Just returning a string works. but the moment I add this anfular.forEach, it stops. In debugger, the loop is working fine and returning the right data.</p>
  
  <p>I know it can be acheved by a filter, but I want to do this way only.</p>