app.module.ts
bootstrap: [AppComponent],
declarations: [AppComponent],
imports: [
CoreModule,
HelloFrameworkModule,
],
providers: [{
provide: Logger,
useFactory: loggerProviderFunc(1),
}]
})
app.component.ts
@Component({
selector: 'my-app',
styleUrls: ['./app.component.scss'],
templateUrl: './app.component.html',
})
export class AppComponent {
constructor(private c:Logger){
}
}
logger.ts
export class Logger {
constructor(private msg: string) {
console.log(this.msg);
}
}
Error:ERROR TypeError: factory is not a function at _callFactory
The value passed in the console is indeed '1', however, I encountered some errors immediately after. Interestingly, when I removed the parameter and simply used 'loggerProviderFunc', the errors disappeared from the console completely.