Now correctly derives currency from value.
This commit is contained in:
parent
6981a5af9f
commit
7e9cfa77c4
1 changed files with 18 additions and 19 deletions
|
|
@ -23,21 +23,12 @@ angular.module('bitcoincom.directives')
|
||||||
controller: function($scope, $timeout) {
|
controller: function($scope, $timeout) {
|
||||||
$scope.canShow = false;
|
$scope.canShow = false;
|
||||||
|
|
||||||
if (!$scope.currency && $scope.value) { // If there is no currency available..
|
|
||||||
// Try to extract currency from value..
|
|
||||||
var currencySplit = $scope.value.split(" ");
|
|
||||||
if (currencySplit.length === 2) {
|
|
||||||
$scope.value = currencySplit[0];
|
|
||||||
$scope.currency = currencySplit[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.displaySizeEqual = !!$scope.sizeEqual;
|
$scope.displaySizeEqual = !!$scope.sizeEqual;
|
||||||
|
|
||||||
configService.whenAvailable(function(config) {
|
configService.whenAvailable(function onConfigServiceAvailable(config) {
|
||||||
console.log("WAIT!!");
|
|
||||||
$timeout(function() {
|
$timeout(function onFormattedAmountTimeout() {
|
||||||
console.log("FIRED!!");
|
|
||||||
var decimalPlaces = {
|
var decimalPlaces = {
|
||||||
'0': ['BIF', 'CLP', 'DJF', 'GNF', 'ILS', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'],
|
'0': ['BIF', 'CLP', 'DJF', 'GNF', 'ILS', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'],
|
||||||
'3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
|
'3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'],
|
||||||
|
|
@ -71,12 +62,20 @@ angular.module('bitcoincom.directives')
|
||||||
return separator;
|
return separator;
|
||||||
};
|
};
|
||||||
|
|
||||||
var formatNumbers = function(currency, value) {
|
var formatNumbers = function() {
|
||||||
|
|
||||||
var parsed = parseFloat(value);
|
if (!$scope.currency && $scope.value) { // If there is no currency available..
|
||||||
|
// Try to extract currency from value..
|
||||||
|
var currencySplit = $scope.value.split(" ");
|
||||||
|
if (currencySplit.length === 2) {
|
||||||
|
$scope.currency = currencySplit[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsed = parseFloat($scope.value);
|
||||||
var valueFormatted = '';
|
var valueFormatted = '';
|
||||||
var valueProcessing = '';
|
var valueProcessing = '';
|
||||||
switch (getDecimalPlaces(currency)) {
|
switch (getDecimalPlaces($scope.currency)) {
|
||||||
case '0':
|
case '0':
|
||||||
if (isNaN(parsed)) {
|
if (isNaN(parsed)) {
|
||||||
buildAmount('-', '', '');
|
buildAmount('-', '', '');
|
||||||
|
|
@ -125,9 +124,9 @@ angular.module('bitcoincom.directives')
|
||||||
$scope.canShow = true;
|
$scope.canShow = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
formatNumbers($scope.currency, $scope.value);
|
formatNumbers();
|
||||||
$scope.$watchGroup(['currency', 'value'], function() {
|
$scope.$watchGroup(['currency', 'value'], function onFormattedAmountWatch() {
|
||||||
formatNumbers($scope.currency, $scope.value);
|
formatNumbers();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue