[英]How to move the content of a textbox into another textbox using AngularJs on button click?
我在其中輸入了特定內容的文本框,如何通過單擊按鈕將該文本框的內容移至另一個文本框........通過清空上一個文本盒子完全。
<div class="col-sm-5">
<p>Invite People</p>
<div class="invite-user-text">
<!-- <input type="text" class="invite-user-input" autocomplete="off"
data-keyboard-layer="invite-user-text" placeholder=""> -->
<tags-input ng-model="tags" display-property="name"
placeholder="Add User" replace-spaces-with-dashes="false">
<auto-complete source="loadCountries($query)" min-length="0"
load-on-focus="true" load-on-empty="true"
max-results-to-show="32" template="my-custom-template"></auto-complete>
</tags-input>
<script type="text/ng-template" id="my-custom-template">
<div class="right-panel">
<span ng-bind-html="$highlight($getDisplayText())"></span>
<span>{{data.email}}</span>
</div>
</script>
我有上面的HTML代碼和js來顯示內容,方法是在文本框中使用ng-input-tag庫。.....我想使用angular將那個content(tags)移動到另一個文本框中單擊按鈕上的js
<button type="button" ng-click=""
class="btn btn-md pull-right add-user-btn" ng-disabled="">
Add Users</button>
</div>
</button>
<div class="col-sm-7 user-text-area">
<p>Deal Administrator</p>
</div>
您也可以將其包裝在控制器的函數中:
<button type="button" ng-click="text=tags">
然后輸入文本:
<input type="text" ng-model="text">
這將在文本輸入中為您提供標簽json。
編輯:
您可以看一下完整的plunkr: https ://plnkr.co/edit/1db1Af ? p = preview
這就是獲取標簽值的方法:
$scope.moveTagsToTextInput = function(){
$scope.text = "";
angular.forEach($scope.tags, function(value, key) {
$scope.text += value.text + " ";
});
$scope.tags = "";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.