html代码如下:
<p ui-sortable="sortableOptionsList[$index]" class="apps-container" ng-model="rawScreens[$index]" ng-repeat="app in rawScreens track by $index">
{{app.name}}
<p ng-repeat="item in app.items track by $index">
{{$index}}{{item.title}}
</p>
</p>
js代码如下:
$scope.rawScreens = itemStorage.itemList('http://localhost:8080/demo/demo.json').success(function(data, status, headers, config) {
$scope.rawScreens = data;
var sol = [];
for (i = 0; i < $scope.rawScreens.length+1; i++) {
sol[i] = createOptions(i);
}
$scope.sortableOptionsList = sol;
});
function createOptions(listName) {
var _listName = listName;
var options = {
placeholder: "app",
connectWith: ".apps-container"
};
return options;
}
json数据如下:
[
{
"id":"状态1",
"name":"状态1",
"items":[{
"title":"测试数据1"
},{
"title":"测试数据2"
}]
},{
"id":"状态A",
"name":"状态A",
"items":[{
"title":"测试数据a"
},{
"title":"测试数据b"
}]
}
]
拖动后在deactivate之后,stop之前报错
1. Regarding the drag-and-drop plug-in, it is recommended to use it
angular-sortable-view
,原因:(1)使用简单方便(2)除了Angular
No additional dependencies are required.2. I have written a small example here. You can click to see it. If it is the result you want, you can read the content below. If you are not satisfied, there is no need to read the content below.
Code part:
1.
index.html
2.
app.js
3.
style.css
Okay, that’s basically it, I hope it can help you ^_^.
1. Official website example portal
2. If there is anything unclear about the code, you can check out my example.