Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call controller's function from another controller / Share data between controllers

For the moment, when I'm in a controller and that I want to call a function from another controller, I do this :

App.app.getControllerInstances()['App.controller.OtherController'].do_something();

Is seems a bit heavy to me, is there another (better) way to do this ?

Thanks

like image 475
Titouan de Bailleul Avatar asked May 19 '12 23:05

Titouan de Bailleul


People also ask

How do you call a controller action from another controller in Web API?

var ctrl= new MyController(); ctrl. ControllerContext = ControllerContext; //call action return ctrl. Action();

How can we call one controller function from another controller in MVC PHP?

Show activity on this post. Create new Helper (e.g PermissionHelper. php ) then move the funtion to it and call it where you want using : PermissionHelper::permission();


1 Answers

I would use the getController method: http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Application-method-getController

EG: this.getApplication().getController('ControllerName').doSomething();

like image 187
badsyntax Avatar answered Oct 23 '22 07:10

badsyntax