lundi 17 avril 2017

Ember Pass property created inside parent component to child components

In my Ember app, I have a property that I create inside the init() method of a parent component. I want to pass this into children.

// app/component/parent.js
import Ember from 'ember';
import ParentProperty from 'somewhere';

export default Ember.Component.extend({
    init() {
        this._super(...arguments);
        let model = this.get('model');
        let moreData = this.get('moreData');
        this.parentProperty = new ParentProperty(model, moreData);
    }

    click(e) {
        this.get('moreData').doSomthing();
    }
});

// app/component/parent.hbs

    // Here, I want to pass the `parentProperty` created 
    // in the init of the parent component.
    


I know I can use the helper to create a ParentProperty, wrap the parent and child, and pass it down to both of them, but that's not what I want to do. Is this possible?




Aucun commentaire:

Enregistrer un commentaire