title: In Angular, how do you increment a counter in the view?
body: <p>For instance, I want have a counter in a recursive script that counts how many times the script has been called.</p>
  
  <p>However, instead of getting a printout of </p>
  
  <pre><code>1
  2
  3
  ...
  </code></pre>
  
  <p>I'm getting </p>
  
  <pre><code>1
  1
  1
  ...
  </code></pre>
  
  <p>Here's my template code:</p>
  
  <pre><code> &lt;div ng-app="App" ng-controller="ctrl"&gt;
       &lt;div&gt;
           &lt;div ng-include="'temp.html'" onload="counter=counter"&gt;&lt;/div&gt;
       &lt;/div&gt;
  
       &lt;script type="text/ng-template" id="temp.html"&gt;
          &lt;h3&gt; {{counter+1}} &lt;/h3&gt;
           &lt;div ng-include="'temp.html'" onload="counter=counter"&gt;&lt;/div&gt;
      &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's my JSFiddle: <a href="http://jsfiddle.net/tp2tuwyy/1/" rel="nofollow">http://jsfiddle.net/tp2tuwyy/1/</a></p>