Angular · Middle · Question 24 of 75
What is the difference between useClass, useValue, useFactory and useExisting?
- ✓Correct answer: Create an instance of a class / use a ready value / call a function to build it / alias another token
- 2They are synonyms for the same thing
- 3They select which component the service is visible in
Explanation
For example { provide: Logger, useClass: ConsoleLogger } swaps an implementation, and useFactory: () => inject(Config).debug ? new DebugLogger() : new Logger() decides at runtime.