blob: ee63c1a5a643023ad4c14b7fe82550c585f34cf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
function formater(format, parse) {return {'format':format, 'parse':parse || format};}
function toString(obj) {return isDefined(obj) ? "" + obj : obj;}
extend(angularFormatter, {
'noop':formater(identity, identity),
'boolean':formater(toString, toBoolean),
'number':formater(toString, function(obj){return 1*obj;}),
'list':formater(
function(obj) { return obj ? obj.join(", ") : obj; },
function(value) {
var list = [];
foreach((value || '').split(','), function(item){
item = trim(item);
if (item) list.push(item);
});
return list;
}
),
'trim':formater(
function(obj) { return obj ? trim("" + obj) : ""; }
)
});
|