How can I add a default value to an Ember model that does not have a data type specified.
import DS from 'ember-data'
export default DS.Model.extend({
// with data type specified
propertyString: DS.attr('string'),
propertyWithDefault: DS.attr('number', {default: 0}),
propertyWithFunctionDfault: DS.attr('date', {
defaultValue() { return new Date() }
}),
// How to set default when no type defined
propertyNoType: DS.attr(),
propertyNoTypeWithDefault: DS.attr(null, {default: 0}) // does not work
})
https://guides.emberjs.com/release/models/defining-models/#toc_options
Aucun commentaire:
Enregistrer un commentaire