pikaday-angular
pikaday-angular copied to clipboard
Sending off Pikaday object through REST
Hey,
I am trying to submit my data through REST and this includes a Pikaday object. Following is the error:
TypeError: Converting circular structure to JSON at Object.stringify (native)
I partially manage to get around by using .getString(), but then I need to check if there is an object (because the function does not work on undefined, in case the date is optional).
Probably something I am overlooking, any suggestion is appreciated!
Hi,
Is there a reason to serialize the whole Pikaday object, including its methods?
I am binding a form including dates. I then submit the model linked to this form to the REST backend through rest-angular. The challenge with pikaday-angular thus is that I would have to replace the dates from the model in the Controller, which is not a huge issue but somehow a bit less elegant.
Furthermore, I am struggling with optional date fields as well.
- I can disable a field, which makes that the property on that model is not present. So calling .getString() function will not work, as the date is undefined.
- If there is a Pikaday object, but no input, then the .getString() does work. However, in my case I can not simply submit an empty string but I need to delete the property. This however is backend specific...
So this leads to some dirty if-else statements in the code. No big deal, just pointing a potential win here for improvement.