jeudi 19 mai 2016

Ember: model defaultValue to another atrribute

I would like to default the value of one of the attribute of the model to another one, if present.

export default DS.Model.extend({

    aRequiredField: DS.attr('date'),

    anOptionalField: DS.attr('date', {
      defaultValue: function () {
        return this.get('aRequiredField') ;
      }.bind(this)
    }),

});

But this does not work, because it seems that the "defaultValue" is computed once before the model is fulfilled.

Is there a clean way to do that, or should I simply use a computed property that has a different name?

Ember: v1.13




Aucun commentaire:

Enregistrer un commentaire