How can i use @inject in constructor? #4932
Unanswered
paulocjota
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My controller code with IProductRepository interface:
Then i get error:
If i change controller code removing IProductRepository interface and adding the ProductRepositoryLucid (real implementation) class everything works fine:
but then i lose the benefits of @Inject.
If i create an abstract class and use it also works, but i hope there are better method:
In Laravel binding interface works out of the box:
https://laravel.com/docs/11.x/container#binding-interfaces-to-implementations
Am i doing something wrong, or is this a typescript issue?
Beta Was this translation helpful? Give feedback.
All reactions