title: How to bind to Elements that have been created via Template System
body: <p>I'm using a template processor like handlebars to build my templates. Since recently I'm using angularjs to handle some JS stuff and would like to bind angular models to some of the elements I created. You have to imagine it like a list of ideas, where each of them has a button for up or downvoting. Clicking the buttons would trigger an ajax request to the server. I'm stuck at the point where I'm not sure how to name my models in this case or in general about the binding, as each idea has an unique id.</p>
  
  <p>What I want to achieve is increment/decrement the number of supporters according to the server reply.</p>
  
  <p>Currently I'm not using ng-repeat for building the list, as I want to preserve the current logic used in my template system.</p>
  
  <p>Here's some code:</p>
  
  <p>Controller:</p>
  
  <pre><code>app.controller('MainController', function($scope) {
      $scope.vote = function(ideaid, vote) {
          $http.get('/' + ideaid + '/vote/' + vote)
              .then(function(result) {
                  // How do I bind to the appropriate element at this point?
              });
      }
  }
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>&lt;div class="idea" id="idea123"&gt;
      &lt;div class="headline"&gt;
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe suscipit dolore vitae nostrum praesentium consequatur.
      &lt;/div&gt;
      &lt;div class="controls"&gt;
          &lt;div class="vote-up"&gt;
              &lt;button class="vote-button up" ng-click="vote(123, 1)"&gt;&lt;/button&gt;
          &lt;/div&gt;
          &lt;div class="vote-down"&gt;
              &lt;button class="vote-button down" ng-click="vote(123, 0)"&gt;&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="vote-details"&gt;
          12 people support this idea
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is there a way to do this? If not what would be the preferred way?</p>