I have a model:
app.ObjectOne = Em.Object.extend({
id: null,
count: null
});
And another model, which computed property ‘SomeProperty’ I want to depend on property ‘count’ from ObjectOne
app.ObjectTwo = Em.Object.extend({
id: null,
someProperty: function(){
return count+5;
}.property('app.SomeObjectController.count')
});
So, can I do it that way?
Or is there any other way to do it;
The main idea is that data of ObjectOne model comes after ObjectTwo, so I what to recompute property and rerender view
If I understand well, the behavior you want is exactly what Ember.js can bring to you.
First, here is a very basic template:
Here is the javascript. I don’t know if you really want to use an ObjectController here, but you mention it, so I have use it. An ObjectController’s act as a proxy around it’s
contentproperty. That means here that someObjectController.get(‘count’) will try to get thecountproperty from the controller itself, and if it does not exist, then the controller retrieve thecountproperty from its content.Here is the working jsfiddle: http://jsfiddle.net/Sly7/M3727/4/