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
1 answer
Angularjs value service & factory service
In angular DOC
Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and…

Kalhan.Toress
- 21,683
- 8
- 68
- 92
0
votes
2 answers
In Angular, is there a way to "provide" a component, similar to a service?
I have an abstract component AbstractPageComponent (an abstract class describing a component), the template of an instance of which can contain an instance of another abstract component. Specifically, an instance of AbstractPageComponent will…

akrick
- 53
- 4
0
votes
1 answer
Storybook-angular error - Type 'EnvironmentProviders' is not assignable to type 'Provider'
after upgrading storybook from 6.5 to version 7.0.23 with angular 16 I met this error:
Type 'EnvironmentProviders' is not assignable to type 'Provider'
Currently found that docs are changed, and providers should be in applicationConfig
const meta:…

Igor Kurkov
- 4,318
- 2
- 30
- 31
0
votes
1 answer
Angular loading mat-spinner not firing
I am wondering why my loading spinner is not firing, and I think it may be due to my confusion in regard to my LoadingService at the app level, and my LoadingService as a provider at the page level.
APP…

Khepf
- 352
- 1
- 4
- 24
0
votes
1 answer
Angular Providers or Providedin
I just can't seem to find the right way on how to use providers and provided in in Angular.
I really did read the documentation on the subject, but there is a basic thing I just cannot get clear.
Suppose I have a service my.service.ts as below where…

hwmaat
- 69
- 5
0
votes
0 answers
Register Angular providers dynamically during runtime
Is there a way to register module/component providers in a dynamic way? I know about the useFactory option but this is only about a specific provider.
What I want to achieve is to register some providers during runtime, via a service instance.
Take…

takthetank
- 55
- 1
- 7
0
votes
1 answer
Modify MatDatePicker for only month picking with overriding date format loacally
I want to make a datepicker in an Angular Material application, only for month picking. In the App Module I set up some providers for date locales which is needed in the app globally.
providers: [
{ provide: LOCALE_ID, useValue: 'hu-HU' },
…

eogabor
- 242
- 4
- 14
0
votes
0 answers
Why can't I get a new function in an AngularJS provider to run?
I have a django application using AngularJS on the front end.
I have added a function to an AngularJS provider (getByEmployeeId).
app.provider('changeTrackingService', function( CTO_LOCAL_STORAGE_BYTES, MEGABYTE_MULTIPLIER, LOGGED_IN_EMPLOYEE) {
…

Rob Dragotta
- 1
- 1
0
votes
2 answers
Angular, Unable to find the root parent by its class interface
From the angular documentation here, I had created a Parent class using
export abstract class Parent {}
Inside the AlexComponent, I had provided this component as Parent to its children
providers: [{ provide: Parent, useExisting: forwardRef(() =>…

bvakiti
- 3,243
- 4
- 17
- 26
0
votes
1 answer
Use defined value in module provider in other Angular module
I would like use provider value defined in other module. Here is example:
app.module.ts
...
import { ThemeModule } from '../shared/modules/theme/theme.module';
...
@NgModule({
declarations: [
RootComponent,
LoginScreenComponent,
],
…
0
votes
0 answers
Why Does property remain undefined in provider service
I am using ng-boostrap and implementing a custom provider for the DateAdapter :
https://ng-bootstrap.github.io/#/components/datepicker/api#NgbDateAdapter
so I did In my module :
providers: [
{ provide: NgbDateAdapter, useClass:…

Bobby
- 4,372
- 8
- 47
- 103
0
votes
2 answers
How to add providers, service and interceptor only for gift card module in angular?
I am implementing caching only for gift card module and I have created http-cache.service and cache interceptor.When I add the service in app.module.ts it works but I need to implement this separately only for giftcard.When I do separately for gift…

Daffodil s
- 11
- 1
- 6
0
votes
1 answer
How can an angular module use another module and instantiate it with custom value?
I need to have a module that does instantiate another one with a custom variable like the following.
// app.module.ts
MyServiceModule.forRoot({
custom: 'customVar'
})
Then within the myServiceModule I try to do the following
#NgModule({
imports:…

Raphaël Balet
- 6,334
- 6
- 41
- 78
0
votes
1 answer
Unique provider value for child component
I am trying to create a reusable date picker component. One of the features is that you can choose a periodLevel. Such as monthly daily or yearly. The problem I have is that when I call this component from a parent component I manipulate the period…

Erik
- 722
- 4
- 11
0
votes
1 answer
Resolve a single token to multiple services in angular
I want a single token to be resolve in two different services at run time in angular component. I am adding the tokens to providers array in module as written below.
providers: [{
provide: ACCOUNT_SERVICE,
useClass: AccountServiceOne
},
{
…

Madhur Maurya
- 1,016
- 4
- 19
- 42