angularjs拖放索引不起作用

时间:2017-06-26 14:15:37

标签: javascript jquery angularjs angularjs-directive html-table

我希望能够拖放表格行并重新排列元素并在模型中更新索引

我在stackoverflow上找到了一个示例,但它似乎无法正常工作,因为索引在拖放后没有更新。

HTML

<div ng:controller="controller">
    <table style="width:auto;" class="table table-bordered">
        <thead>
            <tr>
                <th>Index</th>
                <th>Count</th>
            </tr>
        </thead>
        <tbody ui:sortable ng:model="list">
            <tr ng:repeat="item in list" class="item" style="cursor: move;">
                <td>{{$index}}</td>
                <td>{{item}}</td>
            </tr>
        </tbody>
    </table>

    <hr>
    {{list}}
</div>

<script src="http://code.angularjs.org/1.0.2/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>

JS

var myapp = angular.module('myapp', ['ui']);

myapp.controller('controller', function ($scope) {
  $scope.list = ["one", "two", "thre", "four", "five", "six"];
});

angular.bootstrap(document, ['myapp']);

这是小提琴的链接 http://jsfiddle.net/SSSUUUSSS/Bsusr/1/

0 个答案:

没有答案
相关问题