@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
92 lines (48 loc) • 1.67 kB
Markdown
---
lang: en
title: 'API docs: core.application.controller'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/core
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.
**Signature:**
```typescript
controller<T>(controllerCtor: ControllerClass<T>, nameOrOptions?: string | BindingFromClassOptions): Binding<T>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
controllerCtor
</td><td markdown="1">
[ControllerClass](./core.controllerclass.md)<!-- --><T>
</td><td markdown="1">
The controller class (constructor function).
</td></tr>
<tr><td markdown="1">
nameOrOptions
</td><td markdown="1">
string \| [BindingFromClassOptions](./context.bindingfromclassoptions.md)
</td><td markdown="1">
_(Optional)_
</td></tr>
</tbody></table>
**Returns:**
[Binding](./context.binding.md)<!-- --><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
```ts
class MyController {
}
app.controller(MyController).lock();
```