我正在开发一款价格计算器应用。因此,当用户选择国家和数量(忘记关于短信类型)并点击付费在线按钮时,用户应根据国家/地区货币获得总数。
答案 0 :(得分:1)
考虑一下这个基本的例子:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.value = 0;
$scope.curr = [{
"exchange": 1.0,
"c": "UK",
"s": "£"
}, {
"exchange": 1.38546,
"c": "USA",
"s": "$"
}, {
"exchange": 1.12987,
"c": "EURO",
"s": "€"
}];
$scope.selectedCurrency = $scope.curr[0];
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedCurrency" ng-options="x.c for x in curr">
</select><br>
<input type="number" ng-model="value"><br> {{selectedCurrency.s}}{{selectedCurrency.exchange * value}}
</div>
&#13;