简体   繁体   English

总数转换为单词

[英]Total amount in number to words conversion

I have two fields in my form as shown bellow 我在表单中有两个字段,如下所示

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

Now, I need to display the value amount of my first input field to textarea as one thousand two hundred thirty. 现在,我需要将第一个输入字段的值量显示为textarea 123。

Thanks 谢谢

There is no role of Angular in this. Angular在此没有任何作用。 Its simple logic that you have to use. 您必须使用其简单的逻辑。 This Question is answered here for javascript. 此问题在这里回答了javascript。

UPDATE : This is another solution I found for your problem. 更新是我为您的问题找到的另一个解决方案。

To get you started: Use ng-model to bind to model data and ng-change to react on any change in your input: 要开始使用,请执行以下操作:使用ng-model绑定到模型数据,使用ng-change对输入中的任何更改做出反应:

Total amount: <input type="text" ng-model="data.text" ng-change="countWords()" value="1230"></input>

in your controller: 在您的控制器中:

$scope.data = {text:"", count:0};
$scope.countWords = function(){
  $scope.data.count = [count the words of $scope.data.text...]
};

then display the value in your view: 然后在您的视图中显示该值:

<textarea>{{data.count}}</textarea> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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