Page Contents

Home > @loopback/core > Application > controller

Application.controller() method

Register a controller class with this application.

Signature:

controller(controllerCtor: ControllerClass, name?: string): Binding;

Parameters

Parameter Type Description
controllerCtor ControllerClass The controller class (constructor function).
name string Optional controller name, default to the class name

Returns:

Binding

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();