我的表单中有两个字段,如下所示
Total amount: <input type="text" value="1230"></input>
<br>
<textarea>amount in words goes here..</textarea>
现在,我需要将我的第一个输入字段的值显示为textarea为一千二百三十。
谢谢
答案 0 :(得分:0)
答案 1 :(得分:0)
让你入门: 使用ng-model绑定到模型数据和ng-change以对输入中的任何更改做出反应:
Total amount: <input type="text" ng-model="data.text" ng-change="countWords()" value="1230"></input>
在您的控制器中:
$scope.data = {text:"", count:0};
$scope.countWords = function(){
$scope.data.count = [count the words of $scope.data.text...]
};
然后在视图中显示该值:
<textarea>{{data.count}}</textarea>