我想复制下面的数组列表
$scope.medicinelist = [
{medicine: 'AMLOPRES 5MG TABLET'},
{medicine: 'ARGIPREG SACHET'},
{medicine: 'ALCIPRO 500MG TABLET'} ,
{medicine: 'PROLOMET AM 50MG TABLET'},
{medicine: 'PROLOMET AM 5MG TABLET'},
{medicine: 'AB PHYLLINE 200MG TABLET SR'} ,
{medicine: 'ACIVIR 800MG TABLET DT'},
{medicine: 'CEPODEM AZ TABLET'},
{medicine: 'ECOSPRIN AV 10MG CAPSULE'},
{medicine: 'ECOSPRIN AV 150MG CAPSULE'} ,
{medicine: 'ATORLIP 40MG TABLET'},
{medicine: 'AMTAS 5MG TABLET'},
{medicine: 'ARKAMIN 100MG TABLET'} ,
{medicine: 'AMPOXIN 500MG INJECTION'} ];添加到以下数组列表中
$rootScope.medicinedrop = [
// {
// medicine: 'you try to drop me somewhere'
// }
];我还使用$scope.maedicinedrop从另一个列表进行拖放操作,在复制后,我失去了无法从另一个列表将项目拖放到其中的功能。
按下按钮时
$scope.copy = function(){
console.log($scope.pastprescription)
$scope.medicinedrop.unshift($scope.pastprescriptions.medicine);
}但按下putton后,它只显示空白,即控制台中的数据已复制但不显示。
对于拖放,我使用dragular as:
dragularService([containerLeft_Medicine], {
containersModel: [$scope.allmedicines],
copy: true,
//move only from left to right
accepts: accepts
});
dragularService([containerRight_Medicine], {
containersModel: [$scope.medicinedrop],
removeOnSpill: true,
//move only from left to right
accepts: accepts
});它的ejs文件是:
<input class="form-control" type="text" ng-repeat="medicine_name in medicinedrop"
value="{{medicine_name.medicine}}" /> 发布于 2016-07-18 19:45:23
$Scope.medicinedrop = angular.copy($scope.medicinelist);发布于 2016-07-18 19:47:37
创建一个源的深层副本,它应该是一个对象或数组。
angular.copy(源,目的);
$scope.medicinedrop = angular.copy($scope.medicinelist);参考:here
致以问候。
发布于 2016-07-18 19:44:19
您可以简单地将第一个列表分配给第二个列表
$Scope.medicinedrop = $scope.medicinelist;https://stackoverflow.com/questions/38435827
复制相似问题