Angular JS代码。 2列表,每个列表有内部的项目,点击列表中的一个项目,该项目从列表中删除,并添加到另一个Angular JS编码问题
寻找可重用性:
$scope.move=function(index){
$scope.list2.push($scope.list1[index]);
$scope.list1.splice(index,1);
}
Angular JS代码。 2列表,每个列表有内部的项目,点击列表中的一个项目,该项目从列表中删除,并添加到另一个Angular JS编码问题
寻找可重用性:
$scope.move=function(index){
$scope.list2.push($scope.list1[index]);
$scope.list1.splice(index,1);
}
这是易如反掌:https://plnkr.co/edit/xxTpvxB9GSwAqy25s5GN?p=preview
<body ng-controller="MainCtrl">
<p>List1</p>
<div ng-repeat="item in list1">
<a href="" ng-click="move($index);">{{item}}</a>
</div>
<hr/>
<p>List2</p>
<div ng-repeat="item in list2">{{item}}</div>
</body>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.list1 = [
"12",
"13",
"14"
];
$scope.list2=["223"];
$scope.move=function(index){
$scope.list2.push($scope.list1[index]);
$scope.list1.splice(index,1);
}
});
欢迎来到StackOverflow。请查看帮助菜单,了解有关提问或不提问以及如何提问的问题。 StackOverflow不是代码猴子的社区。 –