title: Angular View: access current node
body: <p>I have the following view:</p>
  
  <pre><code>&lt;div ng-class="setClass($currentNode)"&gt;{{setContent($currentNode)}}&lt;/div&gt;
  </code></pre>
  
  <p>With the following controller:</p>
  
  <pre><code>$scope.setClass = function(currentNode) {
    // Process with angular.element(currentNode);
  }
  
  $scope.setContent = function(currentNode) {
    // Process with angular.element(currentNode);
  }
  </code></pre>
  
  <p>Can I access the <code>$currentNode</code> in which the method is called? From <code>setClass</code>? From <code>setContent</code>? Both?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <h1>EDIT</h1>
  
  <p>Thanks for reply and comments. I know what I am doing, so I'll explain further.</p>
  
  <p>I have in the view:</p>
  
  <pre><code>&lt;div ng-repeat="element in elements" ng-class="setClass(element)"&gt;{{setValue(element)}}&lt;/div&gt;
  </code></pre>
  
  <p>And in the controller:</p>
  
  <pre><code>$scope.setValue = function(element) {
    return callOfAFunctionThatRequiresSomeHardComputation(element);
  }
  
  $scope.setClass = function(element) {
    return callOfAFunctionThatRequiresSomeHardComputation(element) &gt; 0 ? 'active' : '';
  }
  </code></pre>
  
  <p>I don't want to calculate <code>callOfAFunctionThatRequiresSomeHardComputation</code> 2 times on every <code>$digest</code> cycle because it is pretty heavy to compute already.</p>
  
  <p>So I'd rather write:</p>
  
  <pre><code>$scope.setValue = function(element, $currentNode) {
    var result = callOfAFunctionThatRequiresSomeHardComputation(element);
    if (result &gt; 0) {
      angular.element($currentNode).addClass('active');
    } else {
      angular.element($currentNode).removeClass('active');
    }
    return result;
  }
  </code></pre>
  
  <p>I understand that beginners could miss the <em>angular-way</em> easily, but it doesn't mean it is not worth learning how to do it.</p>