samedi 16 septembre 2017

Ember computed property on a DS model record is not firing when the record is changed

Ex:

I have model/test.js

export default Model.extend({
  name: attr('string'),
  email: attr('string'),
  address: attr('string'),
  age: attr(),
  phone: attr()
});

In component.js

list: computed('model.{}', function() { });

Fetching data in route and passing it to the template. In child component i am trying to access it. initially data passed will be like

{
  'data': {
    name: 'test'
  }
}

later sending data as

{
  'data': {
    name: 'test',
    email: 'test@gmail.com',
    address: 'XYZ',
    age: 10,
    phone: 423423
  }
}

But in computed property it is not listening second updated data. I want to listen dynamically each property in model. It will work if i give like

list: computed('model.{name,email,address,age,phone}', function() { });

But i want some other solution for it. Dynamically need to listen each property in model object.




Aucun commentaire:

Enregistrer un commentaire