diff options
| author | Misko Hevery | 2010-01-28 22:10:49 -0800 |
|---|---|---|
| committer | Misko Hevery | 2010-01-28 22:11:01 -0800 |
| commit | a9c182764b5feeb2466c4bb32f7572762f7fab6d (patch) | |
| tree | 48105ad598ca6779e3308b06b12576a366e9be71 /src/Formatters.js | |
| parent | dd9d8bf030688f589af6d47064a0d0eafea41bfa (diff) | |
| download | angular.js-a9c182764b5feeb2466c4bb32f7572762f7fab6d.tar.bz2 | |
added formatters
Diffstat (limited to 'src/Formatters.js')
| -rw-r--r-- | src/Formatters.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Formatters.js b/src/Formatters.js new file mode 100644 index 00000000..74126feb --- /dev/null +++ b/src/Formatters.js @@ -0,0 +1,14 @@ +function formater(format, parse) {return {'format':format, 'parse':parse};} +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) : value; + } + ) +}); |
