From 58f3a118dba44c7c778a92adbe2a30ac9c465051 Mon Sep 17 00:00:00 2001 From: Yann Seget Date: Tue, 12 Jan 2021 20:54:45 +0100 Subject: [PATCH] #642 docs(readme): added service decorator to default DI controller example --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 18235023..91a053f1 100644 --- a/README.md +++ b/README.md @@ -1402,6 +1402,7 @@ That's it, now you can inject your services into your controllers: ```typescript @Controller() +@Service() export class UsersController { constructor(private userRepository: UserRepository) {} @@ -1409,6 +1410,8 @@ export class UsersController { } ``` +Note: As TypeDI@0.9.0 won't create instances for unknown classes, you have to decorate your Controller as a `Service()` as well. See [#642](https://github.com/typestack/routing-controllers/issues/642) + For other IoC providers that don't expose a `get(xxx)` function, you can create an IoC adapter using `IocAdapter` like so: ```typescript