你正在做正確的它應該工作。您可以交叉檢查self
是指控制器和myPanels
使用console.log(self,myPanels)
控制器包含正確的數據\的application.js
import Ember from 'ember';
import moment from 'moment';
export default Ember.Controller.extend({
myPanels:{accordionPanels:[1,2]},
init(){
this._super(...arguments);
//For illustration purpose
Ember.run.later((() => {
console.log('init emer run callback ',this);
this.set('myPanels',{accordionPanels:[3,4,5]});
}),5000);
},
});
模板\ application.hbs
{{#my-accordion accordionPanels=myPanels.accordionPanels as |accordion|}}
From Child :{{accordion}} <br/>
From Parent: {{myPanels.accordionPanels}}
{{/my-accordion}}
{{outlet}}
模板\ components \ my-accordion.hbs
{{yield accordionPanels}}