我有一个简单的货币转换器应用程序,在获取数据后我设置了结果变量,该变量取决于From输入值,但在更改From输入后,结果输入不会改变
$onInit() {
this.currencyService.getData('http://api.fixer.io/latest').then((res) => {
this.data = res
this.values = Object.keys(this.data.rates)
this.result = this.amount * this.data.rates[this.fromVal] / this.data.rates[this.toVal]
this.isLoad= true
})
}
<div class="row">
<div class="col-md-2">
<label>Amout</label>
<input type="number" class="form-control" ng-model='$ctrl.amount'>
</div>
<div class="col-md-2">
<label>Result</label>
<input type="number" class="form-control" ng-model='$ctrl.result'>
</div>
</div>