Controllers - Dependency Injection

Injecting services into controllers

Controllers may use services to delegate requests to business logic. To have these resources injected add corresponding properties to the controller.

CountryService countryService


Important here is the name of the property, not it's type. You could also write it without untyped.

def countryService


If you do want to inject services by type, you can add a property called byName to your controller.

class CountryController {
   def byName = false
   def CountryService whateverNameHere
}




Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.