title: Drag object into sortable list - AngularJS
body: <h2>Problem:</h2>
  
  <p>I'm trying to recreate the Draggable + Sortable functionality from jQuery and can't get the dropped element to go into my array of objects.</p>
  
  <p>I want to drag a <code>$.draggable()</code> button into a <code>$.sortable()</code> list. I want the button to represent an object with properties (could be an associative array, or an object itself) and when I drop it in my list I want it to put itself into the array at the position it was dropped at.</p>
  
  <hr>
  
  <p>Just to be clear, I have an array of <strong>potential</strong> objects in a menu to the left. On the right, I use <code>$http</code> to call my API to retrieve a form that has fields all held in <code>$scope</code>. I want that potential object (like a <code>textarea</code>) to be dropped into that form's fields at the position dropped.</p>
  
  <p>The jquery bit is straightforward but the non-existent object to the position in <code>$scope</code> array is the problem.</p>
  
  <hr>
  
  <h2>What I've tried:</h2>
  
  <p>I was close with mixing combing <code>ui-sortable</code> and <code>$.draggable</code> directive wrapper but my code isn't working very well.</p>
  
  <hr>
  
  <h2>Examples:</h2>
  
  <ul>
  <li><a href="https://jsfiddle.net/cuhuak/4CHDZ/" rel="nofollow noreferrer">KnockoutJS Example</a></li>
  <li><a href="http://jqueryui.com/draggable/#sortable" rel="nofollow noreferrer">jQuery demo</a></li>
  </ul>
  
  <hr>
  
  <h2>Update 1:</h2>
  
  <p>I have made progress with a <code>ui-sortable</code> like directive combined with a directive that wraps <code>$.draggable()</code>, kinda ugly but works.</p>
  
  <h2>Update 2:</h2>
  
  <p>I have it working now but I grab the index from jquery and use PHP to slice it into that position and then reload the entire list.  Talk about lame there must be a better way.</p>
  
  <h2>Update 3:</h2>
  
  <p>Here is a working <a href="http://clouddueling.github.io/angular-common" rel="nofollow noreferrer">example</a> of modularized for anyone's app.</p>