@loopback/docs
Version:
Documentation for LoopBack 4
47 lines (29 loc) • 1.16 kB
Markdown
lang: en
title: 'API docs: core.application.controller'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.core.application.controller.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/core](./core.md) > [Application](./core.application.md) > [controller](./core.application.controller.md)
## Application.controller() method
Register a controller class with this application.
<b>Signature:</b>
```typescript
controller(controllerCtor: ControllerClass, name?: string): Binding;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| controllerCtor | <code>ControllerClass</code> | The controller class (constructor function). |
| name | <code>string</code> | Optional controller name, default to the class name |
<b>Returns:</b>
`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
```ts
class MyController {
}
app.controller(MyController).lock();
```