mardi 19 avril 2016

Injecting application controller into all other controllers

I'm hoping to use my application controller for displaying dynamic modal components. It would be convenient if I could inject the application controller into all other controllers, rather than explicitly injecting it in each controller file where it's needed.

initialize = (app) ->

   app.inject 'controller', 'appController', 'controller:application'
   app.inject 'component' , 'appController', 'controller:application'

InjectApplicationController =
  name: 'inject-application-controller'
  initialize: initialize

`export {initialize}`
`export default InjectApplicationController`

please forgive the coffeescript; this gives me an error, that a controller cannot be injected into other controllers. Is there a workaround?




Aucun commentaire:

Enregistrer un commentaire