title: Using jQueryUI plugins in AngularJS with a data-bound objects array in a ngRepeat loop
body: <p>I'm in the process of learning AngularJS for use in a specific project.
  In this project, there are products that can be customized by editing a list of parameters (specific to the product).
  I'm trying to use ngRepeat in order to render, for each parameter, an input field with a customizable spinner, and a slider.</p>
  
  <p>Since I didn't find suitable plugins/directives/whatever using pure angular, I had to resort to jQueryUI Slider and Spinner plugins.</p>
  
  <p>After some trial and error (and some basic google-fu) I managed to bind the spinner and the slider to the same scope variable, using directives and trying to keep on the "Angular path" as much as possible.</p>
  
  <p>Here's the working fiddle: <a href="http://jsfiddle.net/b8gs60fa/4/" rel="nofollow">http://jsfiddle.net/b8gs60fa/4/</a></p>
  
  <p>Then I tried implementing it using actual parameter data arranged inside an array of objects, and all hell broke loose.</p>
  
  <p>Here's the broken fiddle: <a href="http://jsfiddle.net/wh3qv3rs/1/" rel="nofollow">http://jsfiddle.net/wh3qv3rs/1/</a></p>
  
  <p>First of all, the slider stopped working. The console shows a jQueryUI error "closestHandle is undefined" whenever I try using a slider.</p>
  
  <p>Also, now the slider will be updated by using the spinner, but the model itself will not change. If a value is manually typed into the textbox, then the model is correctly updated, but the slider is not.</p>
  
  <p>My guess is that the problem is being caused by this:</p>
  
  <pre><code>scope.$apply(function() {
      scope[attrs.ngModel] = (parseFloat(ui.value));
  });
  </code></pre>
  
  <p>I'm thinking that data binding is working correctly (because typing in the textbox will change the label as well), but since ngRepeat creates a new scope for each iteration, I'm just referring to (and updating) the wrong object. Sadly, I have no idea how to fix this.</p>
  
  <p>As for the "closestHandle is undefined" error, I have no clue of what's causing it to show up, and I'm secretly hoping that, by solving the binding issue, this one will automagically implode as well.</p>
  
  <p>Thanks in advance.</p>