-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
Is your feature request related to a problem? Please describe.
When I implement md-input-date with DS.attr('date') I cannot successfully store and retrieve a date.
Describe the solution you'd like
I'd like md-input-date to work well with DS.attr('date').
Describe alternatives you've considered
I've instead implemented a new transform that works with my Mongo backend date format. Mongo accepts an ISODate formatted date.
Here is my model.
import DS from 'ember-data';
export default DS.Model.extend({
expires: DS.attr('isodate'),
});Here is my transform ($ ember g transform isodate)
// transforms/isodate.js
import DS from 'ember-data';
import moment from 'moment';
export default DS.Transform.extend({
materializeDateFormat: 'D MMMM, YYYY',
// Load from Store.
deserialize(serialized) {
return moment(serialized).format(this.materializeDateFormat)
},
// Saving to Store.
serialize(deserialized) {
return moment(deserialized, this.materializeDateFormat);
}
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels