I am trying to use APP_INITIALIZER wanted to use a dependency. I read in the official docs that is to add the deps property the object that we are going to use, and then we can use it at the useValue property as a parameter function (cmiiw).
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
SomeService,
{
provide: APP_INITIALIZER,
useValue: (someService: SomeService) => someService.test(),
deps: [SomeService],
multi: true,
},
],
};
Here's the service that is imported:
@Injectable({ providedIn: 'root' })
export class SomeService {
test() {
console.log('okay');
}
}
Tho why does it still gives me an error saying that the object is undefined?