Last active
August 29, 2015 14:07
-
-
Save JonathanGawrych/05739feab2bb1c9117bb to your computer and use it in GitHub Desktop.
transformRequest to make requests made with angular transform Date objects into the long time, rather than iso string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // untested. Probably works. based off of angular's toJsonReplacer | |
| transformRequest: [function(d) { | |
| // why is angular.isFile or angular.isBlob not exposed? Who knows! Code copied here | |
| if (!angular.isObject(d) || | |
| Object.prototype.toString.call(d) === '[object File]' || | |
| Object.prototype.toString.call(d) === '[object Blob]') { | |
| return d; | |
| } | |
| return JSON.stringify(d, function(key, value) { | |
| if (typeof key === 'string' && key.charAt(0) === '$') { | |
| return undefined; | |
| } else if (angular.isWindow(value)) { | |
| return '$WINDOW'; | |
| } else if (value && document === value) { | |
| return '$DOCUMENT'; | |
| } else if (angular.isScope(value)) { | |
| return '$SCOPE'; | |
| } else if (angular.isDate(value)) { | |
| return value.getTime(); | |
| } | |
| return val; | |
| }); | |
| }] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment