我想复制下面的数组列表
$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}}" />
答案 0 :(得分:3)
$Scope.medicinedrop = angular.copy($scope.medicinelist);
答案 1 :(得分:1)
创建源的深层副本,该副本应该是对象或数组。
angular.copy(source,[destination]);
$scope.medicinedrop = angular.copy($scope.medicinelist);
参考:here
问候。
答案 2 :(得分:0)
您可以简单地将第一个列表分配给第二个
$Scope.medicinedrop = $scope.medicinelist;
答案 3 :(得分:0)
Try this,
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="plunker" ng-controller="MainCtrl">
</body>
name = 'ok'
with open('C:/Users/Desktop/text.txt','r') as fin:
for line in fin:
if name in line:
print line