0
我正尝试使用角度ng-change指令和离子框架创建一个简单的货币计算器。在第一次更改后,ng-change在Ionic中不起作用
我可以输入任何输入数据和其他2个更改,但我只能这样做一次,如果我尝试更改另一个文本框而不刷新,代码停止工作(只有1个文本框工作,而不是2,或无文本变更)
这是我的看法代码:
<ion-content>
<h1>Enter Amount</h1>
<h3> Ether </h3>
<label class="item item-input">
<i class="icon ion-social-usd placeholder-icon"></i>
<input type="number" placeholder="ETH" ng-model="eth" ng-change="ethChange(eth)">
</label>
<h3> Chilean Peso (CLP) </h3>
<label class="item item-input">
<i class="icon ion-social-usd placeholder-icon"></i>
<input type="number" placeholder="CLP" ng-model="ethToCLP" ng-change="clpChange(ethToCLP)">
</label>
<h3> Dollars </h3>
<label class="item item-input">
<i class="icon ion-social-usd placeholder-icon"></i>
<input type="number" placeholder="USD" ng-model="ethToUSD" ng-change="usdChange(ethToUSD)">
</label>
</ion-content>
控制器
$scope.ethChange = function(eth) {
$scope.ethToCLP = eth * 30000
$scope.ethToUSD = eth * 50
};
$scope.usdChange = function(usd) {
$scope.eth = usd/50
$scope.ethToCLP = usd * 650
};
$scope.clpChange = function(clp) {
$scope.eth = clp/30000
$scope.ethToUSD = clp/650
};
汇率仅用于测试目的。
我尝试了许多解决方案在那里的计算器,但没有工作对我来说
感谢
您需要对所有三个输入使用相同的ng模型,并为每个输入使用不同的转换公式。 –
谢谢! ,如果所有文本框被调用相同,如何传递参数或更改文本值?关于 – llermaly
好吧,所以他们都应该使用相同的型号,这意味着相同的数据,但是您可以对每个单独应用不同的修改功能。 –