Reputation: 555
The issue I am experiencing is quite clearly expressed in this jsbin, where the computed property isFinito does not change in the template along with the value of isFinished. Is this a feature of components, that they can't listen to computed properties of models passed to them ? If so, how can I achieve this. It seems like a very common need but no matter how much I searched about this, I couldn't find something that duplicates this problem or solves it.
Upvotes: 0
Views: 145
Reputation: 37369
This actually has nothing to do with observers - the cause is property access. Consider the following line:
return (this.isFinished ? "SI" :"NON");
This is always going to return NON
because this.isFinished
is always falsy (it's undefined
). Ember-Data doesn't put data directly on the model instances, it just puts computed properties there. this.isFinished
doesn't exist. If you use Ember's get()
method, it works fine:
return (this.get('isFinished') ? "SI" :"NON");
As a general rule, always use get()
when dealing with Ember objects. I know it's a little annoying at first, but you get used to it and it helps avoid a lot of issues.
Upvotes: 1