angular-dependency-injection Questions

2

Solved

I am doing angular unit testing. Does TestBed.inject(service) create a new instance of the service? I was always under the assumption that TestBed.configureTestingModule() created the service and b...
Enenstein asked 3/6, 2021 at 4:40

4

Solved

In Angular 9 the injectable decorator option providedIn has a new value called any. What is the difference between root and any? Is a service considered a singleton in the case that I use any? @I...

13

In my Angular 9 app, I have an abstract class: export abstract class MyAbstractComponent { constructor( protected readonly cd: ChangeDetectorRef, ) { super(); } // ... } and a Component e...

1

Im faced with a term called "Injection context", and trying to figuring out what it actually is. Coz in angular we have following things that somehow related with injection context (liste...
Formalize asked 12/5, 2023 at 15:11

3

I import a modal library of ng-bootstrap in a lazy module. @NgModule({imports: [NgbModalModule]}) This library has a NgbModal service provided in root. @Injectable({providedIn: 'root'}) class N...
Piet asked 29/1, 2020 at 16:31

2

Solved

In my angular app (with the angular material) I have a filter panel and I want besides select to be able to make autocomplete (user input value and it sends to the back-end, whereby $regexp query w...
Myotonia asked 31/8, 2018 at 7:4

4

In my Angular app, I'm trying to use a factory provider in my module: export function getMyFactory(): () => Window { return () => window; } @NgModule({ providers: [ { provide: WindowRef, ...

6

Is it a good practice to inject 'service' dependencies in @Input properties? The service in this context is not a singleton instance managed at the root level but multiple instances of different im...

1

I working with Angular 8. This question is only for Angular DI experts. At first, I made an Angular library that will be reused in many project. In this Library, I made an abstract service, that...

2

Solved

I'm trying to export a constant in angular and I need to set a key whose value will be returned from a service. I tried with following code: This is my user-config.ts file: export const USER_CONFIG...
Brass asked 30/8, 2019 at 11:39

0

We're well aware that there are various ways of setting config for imported modules. We have '.forRoot()', 'useValue', 'useClass' and such to be used in the importing module. Say for example, we w...

2

I've created two Angular libraries, one has the other as a dependency. the dependency needs to be configured using the forRoot method. how can i pass the configuration data from the parent library ...
Thorrlow asked 19/12, 2018 at 7:58

1

Solved

Just want to make sure I understand the semantics of @Injectable(providedIn: 'root'). Prior to Angular 6 if we import a module from NPM that contains a service we would declare that module in our...

3

Solved

I am using a custom Http provider to handle API authentication error. In my CustomHttp, I need to redirect the user to the login page when a 401 status error is emitted by the API. That works fine!...
Theall asked 29/9, 2016 at 9:50
1

© 2022 - 2025 — McMap. All rights reserved.