Project setup:
- Ember: 2.0.0
- Ember-data: 2.0.0
- Ember-cli: 1.13.8
I have created a transform:
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(serialized) {
serialized = window.moment(serialized).toDate();
if(serialized.toString() === "Invalid Date"){serialized = null}
return serialized;
},
serialize: function(deserialized) {
deserialized = window.moment(deserialized).toISOString();
return deserialized;
}
});
and used it like so:
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Model.extend({
Forename: DS.attr('string'),
Surname: DS.attr('string'),
Gender: DS.attr('string'),
DOB: DS.attr('isodate'),
});
But the transform is not being applied. Has something changed in ember 2.0 that hasn't been updated on the docs that would result in the above not working?
Aucun commentaire:
Enregistrer un commentaire