1
嗨我想從一個子組件發送一個動作備份到父組件,以便它可以訪問this.store並執行數據庫動作。基本佈局是這樣的:發送一個動作從一個子組件到Ember 2.2中的父組件
應用程序/模板/項目/ index.hbs - >確實使用分量
{{#each model as |item|}}
{{item-listing item=item}}
{{/each}}
應用程序/模板/組件/產品-listing.hbs
<li><a {{action 'copyItem' item}}>Copy</a></li>
項的環
在app/components/item-listing.js中,我必須定義一個動作或者我得到一個動作未定義的錯誤。從這裏this.store是不確定的,所以我試圖將這個動作冒泡。
actions: {
copyItem: function(item) {
this.sendAction('copyItem', item);
},
從這裏我迷路了。我試圖把動作上的所有如下:
/app/routes/item/index.js /app/routes/item.js
但它似乎永遠不會讓過去的sendAction電話。我究竟做錯了什麼?
謝謝!必須使用第二種方法。 – Jonathan