Dos filtros nuevos, para monedas y porcentajes
This commit is contained in:
parent
67bd3d96d3
commit
4000926c74
|
@ -0,0 +1,17 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
/**
|
||||
* Override angular currency formats a number adding symbol after value.
|
||||
*
|
||||
* @return {String} The formated number
|
||||
*/
|
||||
export default function currency() {
|
||||
return function(input, symbol, fractionSize) {
|
||||
if (input == null || input === '')
|
||||
return null;
|
||||
if (typeof input == 'number' && fractionSize)
|
||||
input = input.toFixed(fractionSize);
|
||||
return `${input} ${symbol}`;
|
||||
};
|
||||
}
|
||||
ngModule.filter('currency', currency);
|
|
@ -0,0 +1,15 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
/**
|
||||
* Formats a number multiplying by 100 and adding character %.
|
||||
*
|
||||
* @return {String} The formated number
|
||||
*/
|
||||
export default function percentage() {
|
||||
return function(input) {
|
||||
if (input == null || input === '')
|
||||
return null;
|
||||
return input * 100 + ' %';
|
||||
};
|
||||
}
|
||||
ngModule.filter('percentage', percentage);
|
Loading…
Reference in New Issue