In Play Scala 2.5 application, I define my controller like-
class Application @Inject() (ws:WSClient) extends Controller{
Now, I want to call a function readConfig()
of another controller class- ConfigReader
Is there any way to do this, if i am not using services for this particular use cases of sharing functions in controllers?
In play 2.4, with controllers as objects, I could easily do it with Appliation.readConfig()
. How can we do this with controllers as classes ?
Just inject the controller instance:
If you have:
You should be able to inject it into other controllers: