Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transforming value before and after edit #723

Open
piotr-dobrogost opened this issue Mar 19, 2018 · 3 comments
Open

Transforming value before and after edit #723

piotr-dobrogost opened this issue Mar 19, 2018 · 3 comments

Comments

@piotr-dobrogost
Copy link

piotr-dobrogost commented Mar 19, 2018

I would like to use editable-datetime-local field but the problem is Firefox shows plain text input instead proper control for datetime-local field (https://caniuse.com/#feat=input-datetime).
Because of this I need a way to format value stored in a model and present formatted value in edit field. Also I need a way to make Date object myself when editing is finished (sadly Firefox is able to make Date object only from ISO 8601 string which must include 'T' infix and don't handle space instead of this infix for datetime-local field).

How should I go about transforming value before and after edit?

Similar question on SO – Making html5 input field of type “datetime-local” compatible with Firefox

@ckosloski
Copy link
Contributor

What about the combodate
That uses moment.js which should be able to handle any date/time functions you need.

@piotr-dobrogost
Copy link
Author

Thanks for suggestion. I've seen all date and time controls listed in the docs but datetime-local on Chrome and Edge is much nicer and one day it will be available on Firefox too. That's why I wanted to try and make it work. Any idea how to perform my pre and post edit transformations?

@ckosloski
Copy link
Contributor

I guess I'm not 100% sure what you are asking for.
If your value your using is user.date why can't you just format it like $scope.user.date = format your date
For display after saving you have something like {{ (user.date | date: "yyyy-MM-dd") || 'empty' }}
Look into moment.js for handling dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants