samedi 12 novembre 2016

Can an Ember component inherit parent component properties without passing in the template?

I have a few components that come with parent and child parts. As an example, consider an Ember component as a solution to a tab menu, which could look something like this.


  
  
  


The tabs need a way to know which should be selected. The tab-set could have a property called deselector. This could be passed to all the child tab-singles. When a tab-single is clicked, it would toggle the deselector property, which would be observed by all the other child tab-single, ensuring they all all deselected. This would then allow the clicked tab-single to become the selected tab.

It might look something like this...


  
  
  


For every tab I ever make, I'll need to pass in the deselector. Is there a way that I can set the tab-single to always look for a deselector property in its parent tab-set?

That is, is there a way that a child component can always look for a property from its parent component, without it having to passed in the template?

Ta




Aucun commentaire:

Enregistrer un commentaire