Computer properties between Components

If the parent is the enclosing component, and the child component is rendered through the parent’s {{yield}} helper, then the child should have access to properties in the parent component via parentView. There’s an outstanding proposal to rename this to parentComponent for components.

Allow the parent template to wrap the child components:

<script type="text/x-handlebars" id="components/filter-options">
      <h2>{{input type="checkbox" checked=hasSelectAll}} Filter Options</h2>
      {{yield}}
</script>

Then make use of the templates like this:

{{#filter-options}}
     {{filter-option ...}}
     {{filter-option ...}}
{{/filter-options}}

And then in the child controller:

parentHasSelectAll: Ember.computed.oneWay('parentView.hasSelectAll')
1 Like