Page Contents

Home > @loopback/core > Application > controller

Application.controller() method

Register a controller class with this application.

Signature:

controller<T>(controllerCtor: ControllerClass<T>, nameOrOptions?: string | BindingFromClassOptions): Binding<T>;

Parameters

Parameter Type Description
controllerCtor [ControllerClass](/doc/en/lb4/apidocs.core.controllerclass.html)<T> The controller class (constructor function).
nameOrOptions string \| [BindingFromClassOptions](/doc/en/lb4/apidocs.context.bindingfromclassoptions.html) _(Optional)_

Returns:

Binding<T>

The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications.

Example

class MyController {
}
app.controller(MyController).lock();