草庐IT

javascript - angularjs ui-sortable : cannot call methods on sortable prior to initialization; attempted to call method 'refresh'

coder 2025-01-22 原文

我正在尝试对列表进行排序,我从数据库中获取元素但是...

Error: cannot call methods on sortable prior to initialization; attempted to call method 'refresh'

我的 html:

<div class="box-body" >
    <div ng:controller="menuConfigCtrl">
        <ul ui-sortable ng-model="menu"  >
            <li ng:repeat="item in menu |filter:'all' | orderBy:'order':false" >{{item.Title}}</li>
        </ul>
    </div>
</div>

还有我的 Controller :

function menuConfigCtrl($location,$scope, menuFactory) {    
    $scope.menu = [];
    menuFactory.getMenu().success(function(data){
        $scope.menu = data;
    }); 
}

我的 getMenu() 是:

getMenu : function(){
    return $http({
        url: '/api/menuList',
        method: 'GET',
    });
},

如果我不是从 rest 服务获取菜单,而是绑定(bind)它,那么一切正常! 可以是什么?


问题已解决:我导入了 angularjs.js 两次。

最佳答案

问题解决:我导入了两次 angularjs.js。

关于javascript - angularjs ui-sortable : cannot call methods on sortable prior to initialization; attempted to call method 'refresh' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17349889/

有关javascript - angularjs ui-sortable : cannot call methods on sortable prior to initialization; attempted to call method 'refresh'的更多相关文章

随机推荐