在按钮单击时使用AngularJs在另一个文本框中显示文本框的值 [英] Display value of a textbox inside another textbox using AngularJs on button click

查看:59
本文介绍了在按钮单击时使用AngularJs在另一个文本框中显示文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularJs中的新功能。发现它复杂一点。我创建了两个文本框和一个按钮。现在我想,首先我会在第一个文本框中写一些内容。然后我会点击按钮。之后,第一个文本框的值将显示在第二个文本框内。我写了很少的代码,我甚至没有提到按钮点击功能,因为我很困惑。请帮助我走得更远。

New in AngularJs. Finding it complex a little. I have created two text box and a button. Now I want, first I will write something inside the first text box. Then I will click on the button. After that the value of the first text box will get displayed inside the second text box. I have written very little code, I didn't even mentioned the button click function as I am confused on that. Please help me to go further.

<script src="../../Scripts/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-app="">
        <input type="text" ng-model="type">
        <br />
        <br />
        <input type="button" value="button" onclick="myFunction()" />
        <br />
        <br />
        <input type="text" ng-model="display" />
    </div>
</body>

推荐答案

检查这个... Angular JS的例子



http://stackoverflow.com/questions/21693403/angularjs-action-点击按钮 [ ^ ]
check this ...example of Angular JS

http://stackoverflow.com/questions/21693403/angularjs-action-on-click-of-button[^]


这是更新后的代码



Html:



< div ng-app =myAppng-controller =myButtonCtrl>

< input type =textng-model =source >

< br />

< br />

< input type =buttonvalue =按钮ng-click =copyText(source); />

< br />

< br />

< input type =textng-model =目的地/>

< / div>



和JavaScript:



Here is the updated code

Html:

<div ng-app="myApp" ng-controller="myButtonCtrl">
<input type="text" ng-model="source">
<br />
<br />
<input type="button" value="button" ng-click="copyText(source);" />
<br />
<br />
<input type="text" ng-model="destination" />
</div>

and JavaScript:

var myButtonApp = angular.module("myApp", []);

        myButtonApp.controller("myButtonCtrl", [
            "


scope,function(
scope", function (


这篇关于在按钮单击时使用AngularJs在另一个文本框中显示文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆