forked from allenhwkim/angular-jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-currency.js
52 lines (44 loc) · 1.32 KB
/
custom-currency.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* The siteLanguageServices provides information about available languges
* of a site.
*
* @memberof app
* @ngdoc filter
* @name customCurrency
* @param {$http} Test
* @desc
* returns custom currency from the given input
* @tutorial tutorial1
*/
(function() {
'use strict';
var customCurrency = function($http) {
/**
* @func customCurrencyFilter
* @memberof customCurrency
* @desc
* . Create the return function and set the required parameter name to **input**
* . setup optional parameters for the currency symbol and location (left or right of the amount)
* @param {Number|String} input
* @param {String} symbol
* @param {Boolean} place true or false
*/
return function(input, symbol, place) {
// Ensure that we are working with a number
if(isNaN(input)) {
return input;
} else {
// Check if optional parameters are passed, if not, use the defaults
var symbol = symbol || '$';
var place = place === undefined ? true : place;
// Perform the operation to set the symbol in the right location
if( place === true) {
return symbol + input;
} else {
return input + symbol;
}
}
}
};
angular.module('app').filter('customCurrency', customCurrency);
})();