miguelcobain / ember-composability-tools

ember-composability-tools - Helpers for building a somewhat different kind of components.
MIT License
39 stars 18 forks source link

Many parent components of same type receive children that aren't theirs #7

Closed edborden closed 7 years ago

edborden commented 7 years ago

I'm using this plugin to drive a dashboard of google chart widgets that receive results of analytics queries nested like so:

<div>
  {{#some-widget}}
    {{some-query}}
  {{/some-widget}}
</div>
<div>
  {{#some-widget}}
    {{some-query}}
  {{/some-widget}}
</div>

What I'm seeing is that the parent widgets receive all of the some-query components when get('childComponents') is invoked. The solution could be related to https://github.com/miguelcobain/ember-composability-tools/issues/3 but I don't see yet how to pass the parentComponent directly to each child using contextual components. An example would be great.

miguelcobain commented 7 years ago

Sure. Basically you can yield contextual components form another component. Ember-leaflet does that here: https://github.com/miguelcobain/ember-leaflet/blob/master/addon/templates/current/leaflet-map.hbs#L1-L14