简体   繁体   English

如何在单击按钮时使用AngularJs将文本框的内容移动到另一个文本框?

[英]How to move the content of a textbox into another textbox using AngularJs on button click?

I have a text-box with a certain content entered into that,how will i work on to move the content of that text box into an another text box on click of a button........by emptying the previous text box completely. 我在其中输入了特定内容的文本框,如何通过单击按钮将该文本框的内容移至另一个文本框........通过清空上一个文本盒子完全。

<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>

I have the above Html code and a js to that to display the contents has tags by using ng-input-tag library in a text box.....i want to move that content(tags) to the another text box using angular js on click of the button 我有上面的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>

You can wrap this also in a function in your controller: 您也可以将其包装在控制器的函数中:

<button type="button" ng-click="text=tags">

And then your text input: 然后输入文本:

<input type="text" ng-model="text">

This will give you the tags json in your text input. 这将在文本输入中为您提供标签json。

Edit: 编辑:
You can have a look at this complete plunkr: https://plnkr.co/edit/1db1Af?p=preview 您可以看一下完整的plunkr: https ://plnkr.co/edit/1db1Af ? p = preview

And this is how you can get the values of the tags: 这就是获取标签值的方法:

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM