[英]EmberJs - Bubble up action from modal
我有幾個嵌套路線。 在其中一個中,可以打開一個模態(附加到另一個名為模態的出口)。
當用戶輸入文本並單擊“確定”時,它會向MyrouteChildController發送一個動作(“valueUpdated”)。 但是,我還需要將此事件冒泡到MyrouteController,但它無法正常工作。 我嘗試在動作處理程序中返回true,並手動調用@send。
如果我從它自己的模板中調用MyrouteChildController的動作就可以了。
http://emberjs.jsbin.com/lotinaw/edit?html,js,output
任何幫助,將不勝感激。
你不僅可以inject
服務components
和controllers
通過使用灰燼Ember.inject.service()
但你也可能注入控制器和使用發送行動,他們Ember.inject.controller()
然后入手
export default Ember.Component.extend({
mycontroller: Ember.inject.controller('mycontroller'),
funcUsingControllerToSendAction(args){
let mycontroller = this.get('mycontroller');
mycontroller.send('myaction',args);
}
});
這將允許您將帶有參數的操作發送到其他控制器上下文。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.