Suggest an editImprove this articleRefine the answer for “What are factory services?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**Factory services** are services created not directly through a class but via a factory function: instead of the usual `useClass`, `useFactory` is used. **Key point:** a factory service is a way to flexibly control how dependencies are created in DI.Shown above the full answer for quick recall.Answer (EN)ImageFactory services are services **created not directly through a class but via a factory function**. That is, instead of the usual `useClass`, `useFactory` is used: ```typescript providers: [ { provide: MyService, useFactory: (dep: OtherService) => new MyService(dep.config), deps: [OtherService] } ] ``` This lets you: - control **exactly how the object is created** (e.g. depending on the environment or settings); - return **different instances** of the same type under different conditions; - inject dependencies manually through the `deps` parameter. Essentially, a factory service is a way to **flexibly control the creation** of dependencies in DI.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.