element.sortable 不是一个函数 Angular

element.sortable is not a function Angular

本文关键字:一个 函数 Angular sortable element      更新时间:2023-09-26

我正在尝试使用 ui.sortable 创建一个可排序的列表。我遵循了 https://github.com/angular-ui/ui-sortable 但我仍然无法让它工作并收到此错误消息类型错误:element.sortable 不是一个函数。我使用以下方法加载jquery和jquery-ui:

<script src="js/jquery-2.2.3.js"></script>
<script src="js/jquery-ui.js"></script>

但仍然没有运气。我使用angularJS + Spring引导系统:https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application。提前致谢

因此,经过一些研究,我发现该应用程序利用了Wro4j,需要通过wro.xml文件导入webjars。因此,如果在这种情况下jquery-ui中的JS依赖项作为webjar存在,则可以将其添加到应用程序中。为我工作。

您需要

在$scope中注册ui.sortable。例如:如果函数被调用为 elementSort()

function mainController ($scope, $http){
    $scope.elementSort =  function(data){
    console.log(data);
    }
}