Javascript 将数组列表复制到另一个数组列表

Javascript 将数组列表复制到另一个数组列表,javascript,angularjs,sails.js,Javascript,Angularjs,Sails.js,我想复制下面的数组列表 $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 TAB

我想复制下面的数组列表

$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作为:

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}}" /> 

您只需将第一个列表分配给第二个列表即可

 $Scope.medicinedrop = $scope.medicinelist;

创建源的深度副本,该副本应为对象或数组

复制(源[目的])

参考文献:

问候。

var-app=angular.module('plunker',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.medicinelist=[
{药物:'AMLOPRES 5MG片剂'},
{medicine:'ARGIPREG香包'},
{药物:'ALCIPRO 500MG片剂'},
{药物:“PROLOMET AM 50MG片剂”},
{药物:“PROLOMET AM 5MG片剂”},
{药物:“AB PHYLLINE 200MG片剂SR'},
{药物:阿昔韦800MG片剂DT'},
{药物:'塞波德姆AZ片剂'},
{药物:“ECOSPRIN AV 10MG胶囊”},
{药物:“ECOSPRIN AV 150MG胶囊”},
{药物:'ATORLIP 40MG片剂'},
{药物:'AMTAS 5MG片剂'},
{药物:“阿卡明100MG片剂”},
{药物:'氨苄500毫克注射液'}];
$scope.medicinedrop=[{medicine:'TEST'}];
$scope.medicinedrop=$scope.medicinelist.concat($scope.medicinedrop);
console.log($scope.medicinedrop);
});
试试这个,

但按putton键后,仅显示空白,即控制台中的数据已复制但未显示。
这是什么意思?我已尝试了两个选项,但实际上我也在使用$scope.maedicinedrop进行拖放操作,执行此操作后,我将失去无法将项目拖放到其中的功能从另一个列表中。@RAJDUBEY很难理解您在一行语句中谈论的拖放功能。你能问一个简单的问题吗?你在哪里向我们展示了所有的代码,我们可以解决这个问题?副本正在工作,但无法在复制后执行拖放。你正在做的拖放操作我正在使用dragular drag drop.dragularService([containerLeft_Medicine],{ContainerModel:[$scope.allmedicine],copy:true,//仅从左向右移动接受:接受});dragularService([containerRight_Medicine],{ContainerModel:[$scope.medicinedrop],removeOnSpill:true,//仅从左向右移动接受:接受});
$Scope.medicinedrop = angular.copy($scope.medicinelist);
$scope.medicinedrop = angular.copy($scope.medicinelist);