Search code examples
angularprovider

Using provider to create another provider


I'm trying to using the same provider, and to inject it to another provider during the bootstrap time.

  { provide: '$http', useFactory: (config: any) => httpFunc(config), deps: [configService] },

  { provide: '$pab', useFactory: (config,  http) => new pabLite(config, http), deps: [configService, Inject('$http') http] }

dosent seem to work. how can i inject to the $http provider ,when creating the $pab provider ive tried as well to move the Inject('http') private http inside the pablite, but it dosent seem to work getting undefined when initals


Solution

  • You should provide it as:

    deps: [configService, http$]