element.sortable不是函数Angular

问题描述:

我试图使用ui.sortable创建一个可排序的列表。我跟着https://github.com/angular-ui/ui-sortable,但我仍然无法得到它的工作,并得到这个错误消息TypeError:element.sortable不是一个函数。我加载jQuery和jQuery-ui使用:element.sortable不是函数Angular

<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。因此,如果在这种情况下JS的依赖jquery-ui,作为一个webjar存在,你将能够将其添加到应用程序。为我工作。

您需要注册$ scope中的ui.sortable。 例如:如果函数被称为elementSort()

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

不真正明白你的意思 –

+0

你在angularJS + Spring引导系统中得到TypeError不是因为你只是加载jQuery库的方式。要使用ui.sortable,您正在使用的函数需要按照上面在$ scope中显示的方式进行注册。 – Vaish

+0

请给予更多解释..你在说什么功能?代码应该放在哪里?他为什么需要这样做? –