I have a component with a few sub-views and I would like that one of those views to be able to observe one of its parent’s properties. Is that possible? and if not, how can I achieve it?
I’m able of showing in the console the info of that property by typing ‘controller.propertyX’ but when I try to observe it does nothing.
In bottom-component you should have access to parentFoo e.g.
//bottom-component.js
import Ember from 'ember';
export default Ember.Component.extend({
someFunction: function() {
var pFoo = this.get('parentFoo');
// do something interesting with it!
}
});
Basically you’re just passing the property into the bottom component explicitly, rather than the bottom component asking its parent for the property of its parent!
So it needs to go through each element between the parent and the desired child. Isn’t it adding a lot of unnecessary properties to the intermediate children?
There are many others, but this seemed reasonable based on the description you gave. Without a bit more context and / or code sample, it’s difficult to offer alternatives.