I'm working on a little test code using angular-dragula and I have managed to get the drag-and-drop thing working, but it's not updating the source data array.
I declare some variables in the angular controller:
$scope.todos=['Stuff','Thangs'];
$scope.plan=new Array(($scope.endTime - $scope.startTime)*(60/$scope.timeBlock));
for(var i=0;i<$scope.plan.length;i++){
$scope.plan[i]=["-"];
}
Which is perhaps not hte best way to initialise, but I get an array of arrays, each containing an "placeholder" character.
The HTML then draws this out:
<div ng-app='dayplannerApp' ng-controller="MainCtrl">
<div class='wrapper'>
<button ng-click='dump()'>Dump</button>
<div class='container' id='source-box' dragula='"first-bag"' dragula-model='todos'>
<div id="source" ng-repeat='text in todos' ng-bind='text'></div>
</div>
<hr>
<div class='container'><pre>{{plan[0] | json}}</pre></div>
<div class='container'><pre>{{plan[1] | json}}</pre></div>
<hr>
<table ng-repeat="n in Range()" border='1'>
<tr ng-class-odd="'odd'" ng-class-even="'even'" ><td width='20%'>{{n}}</td><td>
<div class='container' dragula='"first-bag"' dragula-model='plan[$index]'>
<div ng-attr-id="{{ 'block-' + n}}" ng-repeat='text in plan[$index]' ng-bind='text' ng-click='setId($event)'></div>
</div></td></tr>
</table>
</div>
</div>
This seems to work, I can drag 'stuff' or 'thangs' over to the divs that contains the ng-repeat and can drop them there, the two "pre" containers are updated if I drop things in the first two rows.
But when I try to dump the underlying "plan" array with:
console.log($scope.plan);
I just get the original array of array with only the placeholders. Am i doing something wrong with the model assignment? or the binding? Why does plan[1] get updated in the div, but not in the javascript?