[英]ng-change not working in Ionic after the first change
我正在嘗試使用angular ng-change指令和Ionic Framework創建一個簡單的貨幣計算器。
我可以在任何輸入上輸入數據,而其他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
};
匯率僅用於測試目的。
我在stackoverflow中嘗試了許多解決方案,但沒有一個對我有用
謝謝
嘗試在代碼上放置斷點並檢查值。 您的公式可能返回相同的值。 調試每個文本框的ng-change功能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.