Questions tagged [angular-di]

34 questions
0
votes
1 answer

Angular 4 inject console with AOT

This code fails in development mode with Ahead of time compilation. export function loggerFactory(console, http, device, injector) { return environment.production ? new LogstashLoggerService(device, injector, http) : new…
Serginho
  • 7,291
  • 2
  • 27
  • 52
0
votes
1 answer

useFactory vs useValue with AoT compilation

I use window.location to setup for injectable. In my module near imports I define variable const flag = window.location.search.includes('flag'); ... { provide: FLAG, useValue: flag }, and it works as expected with JIT compilation But when I switch…
mgrinko
  • 515
  • 1
  • 4
  • 13
0
votes
1 answer

Can I use custom ReflectiveInjector strategies to get component providers?

As you all know we have different strategies for providers: useClass, useExisting, useFactory, useValue. But what if I would like to add own strategy? Something like: providers: [ { MyService: MyService, useAsyncFactory: MyAsyncFactory} ] What is…
Stepan Suvorov
  • 25,118
  • 26
  • 108
  • 176
-2
votes
1 answer

Can't resolve all parameters for component

I'm facing this pretty common issue. Trying to inject a service to a component. But getting this Can't resolve all parameters for VehicleComponent error. Don't know why it's happening. Tried to put @Inject on dependency parameter, tried to provide…
aliemre
  • 109
  • 3
  • 12
1 2
3