使用按钮复制和粘贴输入 - Angular 1

时间:2017-05-16 11:09:01

标签: javascript angularjs

我想复制在一个输入中输入的数据,然后使用按钮将它们粘贴到另一个输入中。

这是一个截图:

enter image description here

你有想法如何使用JavaScript / Angular 1完成它?还是另一个回答这个问题的质量保证?

1 个答案:

答案 0 :(得分:0)

使用angularJS

<强>控制器

// your first input data
$scope.country1 = "";

// your second input data
$scope.country2 = "";

// the copy function
$scope.copy = function() {
 $scope.country2 = $scope.country1;
}

查看

<!-- Your first input -->
<input type="text" ng-model="country1" ng-model-options="{ debounce: 1000 }"/>

<!-- Your button -->
<button ng-click="copy()">Copy</button>

<!-- Your second input -->
<input type="text" ng-model="country2" ng-model-options="{ debounce: 1000 }"/>