'private' is skipped
Closed this issue · 0 comments
https://angular-book.dev/ch06-05-injecting-multiple-instances.html
hello! On this lesson 'private' is skipped. So the code do not compile without it
// src/app/services/composite-log.service.ts
import { Injectable, Inject } from '@angular/core';
import { LOGGER_PLUGIN } from './../tokens';
export interface LogPlugin {
name: string;
level: string;
log(message: string);
}
@Injectable({ providedIn: 'root' })
export class CompositeLogService {
constructor(@Inject(LOGGER_PLUGIN) plugins: LogPlugin[]) {
if (plugins && plugins.length > 0) {
for (const plugin of plugins) {
console.log(Loading plugin: ${plugin.name} (level: ${plugin.level})
);
}
}
}
log(level: string, message: string) {
const logger = this.plugins.find(p => p.level === level); // error here (plugins do not exist...)
if (logger) {
logger.log(message);
}
}
}