我正在建立一个angularjs/firebase应用程序unsing angularfire绑定(v0.5.0).
我有一个项目列表,显示在一个表格ng-repeat中<tr>,如下所示:
<table>
<tbody>
<tr ng-repeat="(index, item) in items">
<td>
<input type="checkbox" ng-model="item.done">
</td>
<td>
<input type="text" ng-model="item.text" ng-focus="onItemFocus(index)" ng-blur="onItemBlur(index)">
</td>
<td>
<button type="button" ng-click="remove(index)">×</button>
</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
并且在这个项目列表上有一个angularfire 3路数据绑定,如:
$scope.ref = new Firebase('...');
$scope.remote = $firebase($scope.ref);
$scope.remote.$child("items").$bind($scope, "items");
Run Code Online (Sandbox Code Playgroud)
这一切都很好,但现在我正在尝试添加拖放重新排序项目的可能性.
我设法使用jquery-ui(基本上是调用$("tbody").sortable())来设置拖放UI ,但我的问题是将它绑定到角度模型.有一个数量 的 问题就在于(与大jsfiddles),但在我的情况下angularfire 3双向绑定似乎搞乱它.
我想我需要在angularfire中使用firebase 优先级,orderByPriority并且可能在其中一个sortable回调中处理它,但是我很难弄清楚我应该怎么做...并且找不到任何关于它的文档.
有没有人做过类似的事情,你能否分享一些如何设置它的指针?