如何从视图将操作从一个控制器/路由器发送到另一个控制器/路由器
How do you send an action from one controller/router to another from a view?
我在视图中,我想将操作发送到与我所在的视图不同的控制器或路由器。我该怎么做?
App.FormView = Ember.View.extend ({
actions: {
clicked: function() {
context = this.get("context");
App.OtherViewController.send("clicked", context); //this doesn't work
// this.get("controller").send("clicked", context); // this sends to the current controller
}
}
});
如果你的FormController
needs
一些ThingController
你可以通过做this.get('controller.controllers.thing')
把它放在FormView
里。 从内部FormController
你会使用this.get('controllers.thing')
.
App.FormController = Ember.ObjectController.extend({
needs : ['thing']
});
App.FormView = Ember.View.extend ({
actions: {
clicked: function() {
context = this.get("context");
// this sends to the ThingController
this.get("controller.controllers.thing").send("clicked", context);
}
}
});
相关文章:
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- Ui路由器:获取控制器中视图的名称
- 堆叠有角度路由器添加控制器
- Ember.js:如果控制器中满足某些条件,则在路由器中重定向
- 使用UI路由器实现控制器A的最佳实践方法
- 如何将值与$scope绑定,以从定义状态ui路由器的控制器中使用ng模型进行查看
- AngularJS:控制器在使用UI路由器更改状态时多次注册
- EmberJS:如何从控制器转换到路由器's的操作
- 让我的角度控制器检查一下ui是怎么看的's位于ui路由器中
- 如何使用铁路由器用一个路由控制器渲染多个模板
- AngularJS UI 路由器:包含控制器脚本的位置
- UI 路由器 AngularJS 控制器无法使用状态
- 如何在使用具有嵌套视图的 ui 路由器时添加用户控制器
- Ember 路由器中的“this._super(控制器,型号)”是什么意思?
- 如何使用requireJs以正确的顺序定义控制器,路由器和应用程序
- 在铁路由器控制器中调用函数
- ng-controller工作,UI路由器:控制器不是
- Angularjs UI路由器控制器在解析后未更新
- Ember.js 路由器/控制器属性
- 流星订阅在铁:路由器控制器是't工作