autoInject Behaviour

Quick question when using @autoInject do instances get resolved as singleton or transient by default (without manually registering things in the IOC container)?

1 Like

Singleton by default.

https://aurelia.io/docs/fundamentals/dependency-injection/

container.registerSingleton(key: any, fn?: Function): void - This method allows you to register a class as a singleton. This is the default, as discussed above, so there’s rarely a reason to call this method. It is provided in the API for completeness.

2 Likes