Philipp Huber
What do you already know about Dependency Injection in Angular?
Where to provide dependencies?
@Injectable({providedIn: 'root'})
export class Service {..}
@Injectable({
providedIn: 'root',
useFactory: () => new MusicService('dependency'),
})
[{ provide: Logger, useClass: TimestampedLogger }],
[Logger]
[{ provide: Logger, useClass: TimestampedLogger },
{ provide: BasicLogger, useExisting: Logger}]
export function SilentLoggerFn() {}
const silentLogger = {
logs: ['Silent logger says "Shhhhh!". Provided via "useValue"'],
log: SilentLoggerFn
};
[{ provide: Logger, useValue: silentLogger }]
[{ provide: MusicService,
useFactory: musicServiceFactory,
deps: [Logger, UserService]}]
What is the injection tree?
ModuleInjector & ElementInjector
How does Angular resolve tokens?
What is the difference between providers and viewProviders?
What are resolution modifiers and how do they work?
What about lazy-loaded modules?