mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
18 lines
583 B
JavaScript
18 lines
583 B
JavaScript
function formater(format, parse) {return {'format':format, 'parse':parse || format};}
|
|
function toString(obj) {return ""+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) {
|
|
return value ? _(_(value.split(',')).map(jQuery.trim)).select(_.identity) : [];
|
|
}
|
|
),
|
|
|
|
'trim':formater(
|
|
function(obj) { return obj ? $.trim("" + obj) : ""; }
|
|
)
|
|
});
|