Question about the 'ember way' of handling nested views for this case. Using ember-cli -- I have a resource named 'customers'. The view hierarchy is:
customers
+- customers.index
+- customers.show
I would like to place a banner at the customers level, but have a portion of it's contents specified at the .index or .show level.
So I add a property to the customers controller and show that in a customers template.
import Ember from 'ember';
export default Ember.Controller.extend({
headingText: 'initial'
}
template
<h3>{{ headingText }}</h3>
{{ outlet }}
The child controllers can see the value, but upon changing it -- the view does not change (prototype -vs- inheritance?)
In order to change the headingText from a child controller, I need to do this in each child:
needs: "customers",
headingText: Ember.computed.alias("controllers.customers.headingText")
Is this the 'ember way'? Seems like there should be an easier way to bubble up information without the boilerplate (method on customers controller or something).
Assuming the header text will contain information from a resolved model, where is the best place to set it? In the route? aftermodel?
Thanks
Aucun commentaire:
Enregistrer un commentaire