define(['app/app'], function(app) { 'use strict'; app.register.controller('exchangeRateCtrl', ['$scope', 'exchangeRateService', 'toaster', function($scope, exchangeRateService, toaster) { $scope.edit = false; exchangeRateService.getUSD(null, function(date) { $scope.usdExchangeRate = date.data; }, function(response) { toaster.pop('error', '获取信息失败:' + response.data); }); $scope.save = function() { if ($scope.usdExchangeRate.fromCurrency == null || $scope.usdExchangeRate.fromCurrency == '') { $scope.usdExchangeRate.fromCurrency = 'USD'; $scope.usdExchangeRate.toCurrency = 'RMB'; $scope.usdExchangeRate.type = 'USD'; } exchangeRateService.save(null, $scope.usdExchangeRate, function(data) { $scope.usdExchangeRate = data.data; $scope.edit = false; toaster.pop('success', '保存成功'); }, function(response) { toaster.pop('error', '保存信息失败:' + response.data); }); }; $scope.modify = function() { $scope.edit = true; }; $scope.cancle = function() { $scope.edit = false; } }]); });