title: Bind a method to each item in an array
body: <p>I'm having difficulty figuring out the syntax for binding a function to each item in an object array in JavaScript/Angular.</p>
  
  <p>I've tried various approaches, and while probably not syntactically correct, I feel like the approach I have here is logically on the right track.</p>
  
  <pre><code>var module = angular.module('app', [])
    .controller('controller', function () {
      var vm = this;
  
      vm.foo = 5;
      vm.bars = [
        {
          price: 1000
        },
        {
          price: 2000
        }
      ];
  
      var qty = function () {
        return vm.foo / this.price;
      };
  
      for(var i = 0; i &lt; vm.bars; i++) {
        vm.bars.bind(vm.bars[i], qty);
      }
    });
  </code></pre>
  
  <p>My thought is that binding each item's <code>this</code> to itself, would be the best way to allow each item to reference its own <code>price</code> property in the <code>qty()</code> function, which lives outside of the object.</p>
  
  <p>I'm basically just trying to avoid copy/pasting a function as a property of each item when setting up the array.</p>