在按钮单击时使用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 (