Angular · Middle · Question 24 of 75

What is the difference between useClass, useValue, useFactory and useExisting?

Explanation

For example { provide: Logger, useClass: ConsoleLogger } swaps an implementation, and useFactory: () => inject(Config).debug ? new DebugLogger() : new Logger() decides at runtime.

Further reading

Problem with a question

Angular · Middle · question 24

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz