单词转换的总数量

时间:2015-10-19 10:07:41

标签: javascript jquery angularjs

我的表单中有两个字段,如下所示

Total amount: <input type="text" value="1230"></input>
<br>
<textarea>amount in words goes here..</textarea>  

现在,我需要将我的第一个输入字段的值显示为textarea为一千二百三十。

谢谢

2 个答案:

答案 0 :(得分:0)

Angular在这方面没有任何作用。它必须使用它的简单逻辑。对于javascript,此问题的回答为here

更新This是我为您的问题找到的另一种解决方案。

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