The service providers are constructor functions. When instantiated they must contain a property called $get, which holds the service factory function.
Questions tagged [angular-providers]
173 questions
1
vote
0 answers
TranslateModule.forRoot returns a ModuleWithProviders type without a generic type argument
I have migrated my angular application from version 5 to version 9. When I am trying to build it is throwing below error.
"TranslateModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument…

Bhushan Khaladkar
- 420
- 1
- 7
- 20
1
vote
1 answer
How can I get data from service in Angular interceptor?
I want to add my authentication token in the request header in my auth.interceptor.ts and I'm keeping the authentication token value in my auth.service.ts.
Here's auth.interceptor.ts
@Injectable()
export class AuthInterceptor implements…

Vala Khosravi
- 2,352
- 3
- 22
- 49
1
vote
0 answers
Factory does not return value from provider after Angular update
In app.module.ts has the following provider:
{
provide: LOCALE_ID,
useFactory: (translate: TranslateService) => translate.currentLang,
deps: [TranslateService]
}
I have updated angular version from 8.2 (iteratively to 12).
Everything…

ArtoriasDF
- 19
- 2
1
vote
1 answer
Configure a external Angular lib with .forRoot() that depends on a main Application service for populate config values
I have a custom Library that needs custom configuration within the forRoot() Library module, but I need to use an App Config Module that loads that configuration asynchronously instead of using static injected data as following.
// Custom Library…

frankfullstack
- 498
- 5
- 18
1
vote
1 answer
Dialog opened by custom ErrorHandler provider in response to async event does not close
I have a general Alert Dialog component that I use for various purposes throughout an Angular application (simplified)...
@Component({
selector: 'app-alert-dialog',
template:…

Nickolas Hook
- 774
- 5
- 13
1
vote
1 answer
Access component's provider from another component in angular
I have a library with a component that has a provider, like so-
@Component({
selector: "lib-layer-list-widget",
templateUrl: "./layer-list-widget.component.html",
styleUrls: ["./layer-list-widget.component.css"],
providers:…

Shaked
- 93
- 1
- 9
1
vote
2 answers
Angular restrict service to only one component tree
i want to implement a service and let it provide to only one named component or module and not to any other component or module.
So whenever anyone tries to provide that service to another component they get an error and the program should not…

Vipin Jain
- 1,382
- 1
- 10
- 19
1
vote
2 answers
Providers functionality in angular
I created a component and service in my project. According to documentation while using the service you should include it in providers metadata of the component where you are going to inject it. However, I noticed it works fine if I don't mention it…

Ankita Prasad
- 57
- 1
- 9
1
vote
0 answers
Is it possible to change provider of component in Angular Material Dialog?
I have a component with InjectionToken and custom provider to get data from store. In base usage of the component I need to provide data with "user logins", but in dialog I need to get "user names" with the same component. Is it possible to pass…

fiorsaoirse
- 26
- 2
1
vote
0 answers
Create dynamic provider in angular
In my angular project I provide a configuration object using a function like this:
@NgModule({
imports: [CommonModule, UrlModule, I18nModule, RouterModule],
providers: [
provideConfig(defaultConfig),
provideConfig(
...
),
…

cristid9
- 1,070
- 1
- 17
- 37
1
vote
0 answers
Angular: NullInjectorError: No provider for InjectionToken config
I'm getting this error:
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[InjectionToken config]:
StaticInjectorError(Platform: core)[InjectionToken config]:
NullInjectorError: No provider for…

Matt123
- 556
- 3
- 15
- 36
1
vote
3 answers
NullInjectorError: No provider for t! NullInjectorError: StaticInjectorError(ba)[Cw -> t]:
When I run my prod build of my Angular 8 app, I am getting this error in console. The build runs fine and I've included all services in my provider.
I've run the following commands but do not get any errors.
ng build --prod --optimization=false
Is…

roonz11
- 795
- 1
- 13
- 24
1
vote
2 answers
How to set value for provider gathered from API backend in Angular
how can I set value here from API ?

kamilws
- 171
- 1
- 16
1
vote
1 answer
Angular `useFactory` Service Setup throwing Uncaught Error: Can't Resolve all parameters for Component
Working with angular for the first time in a long while and I'm trying something very new. I have a service, that I want to behave a bit differently based on how it's created, and I assumed that useFactory would be the right way to go, but I'm…

Chris Rutherford
- 1,592
- 3
- 22
- 58
1
vote
2 answers
Angular 2 error NullInjectorError: No provider for Http
I am trying to read a json github service and I am getting an error NullInjectorError: No provider for Http!
I already to add providers all over the code but it is not working I dont know what is causing the error but know where it is happening…

C-zar
- 41
- 1
- 3