-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Why my custom decorator injects the ContainerInstance? #571
Comments
The container injects itself as the last parameter for historical reasons. If you get the container for the It's not optimal, but I think this is the reason for this behavior. (Can be wrong, I haven't touched this repo in a while) |
@NoNameProvided, Ok, but is there any way to inject a custom value that is not in the container? In the example, in my code I want to inject the value of dbName |
You need to register it first. |
I have that code: export default function InjectConnection(dbName: string) {
return (object: any, propertyName: string, index: number) => {
Container.registerHandler({
object,
propertyName,
index,
value: (containerInstance) => {
const connection = createConnection(dbName);
console.log("Connection %s created", dbName);
return connection;
},
});
};
} But is not working and the |
I am creating my custom decorator InjectConnection:
And I am tryíng to use it in a service:
But, in the console.log the ContainerInstance is printed
The text was updated successfully, but these errors were encountered: