I'm attempting to sort a list, where I retrieve the elements from a database but...
Error: unable to call methods on sortable before initialization; tried calling method 'refresh'
This is my 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>
And here's my controller:
function menuConfigCtrl($location,$scope, menuFactory) {
$scope.menu = [];
menuFactory.getMenu().success(function(data){
$scope.menu = data;
});
}
The getMenu()
function is defined as follows:
getMenu : function(){
return $http({
url: '/api/menuList',
method: 'GET',
});
},
If I retrieve the menu items without using a REST service and just bind them directly, everything works fine with no errors! Any ideas why?
Problem identified: The issue was caused by mistakenly importing angularjs.js
library twice.