Skip to main content
2 votes
0 answers
70 views

Route level providers - how to provide them in test

I think there is no possibility to provide mock for any route level provided Services. Creation of test routes to override it has no sense when need to test on real routes. @Injectable() export class ...
turtle's user avatar
  • 41
1 vote
0 answers
168 views

Getting Error : NG0203: `inject()` must be called from an injection context > such as a constructor

Getting this error after upgrade Angular Version 14 to 18. Till version 16 application working fine but in Version 18 it showing error. It showing error on main.ts file 69 line. ERROR : NG0203: ...
Sunil Kumar's user avatar
0 votes
0 answers
302 views

Angular Upgrade v19 Dev Builds Fine but Prod Build Runtime Error NullInjector

We recently upgraded the Angular app to version 19. Dev build is running fine, but in prod build we are getting the below error. My prod settings are below in angular.json file "optimization&...
Dhimant Bhensdadia's user avatar
1 vote
1 answer
51 views

Provide CustomPipe instead of CurrencyPipe

I want to provide CustomPipe instead of CurrencyPipe. Expected to import and use default CurrencyPipe, but it will use CustomPipe instead of it. I use this provider { provide: CurrencyPipe, ...
Herman Vasilkouski's user avatar
3 votes
2 answers
191 views

Can we remove all the constructor-based injections?

Recently, Angular put in place a migration to replace constructor-based injection with inject function. In most of the cases, it is straightforward and it clearly has benefits: // before @Injectable({ ...
fservantdev's user avatar
0 votes
2 answers
283 views

Angular 18 Multiple instance of same service

I've: service DataLoader who read/write data in DB. service Report who instances DataLoader using inject standalone component who inject DataLoader and Report too. At this point, only one instance of ...
Jeferson Fillipe's user avatar
0 votes
1 answer
114 views

Angular component with content projection causes incorrect service injection

I have an Angular directive (LevelDirective) designed to determine its level based on its parent's level (i.e. if parent has level 1 => I should have level 2). It uses a standalone LevelService to ...
Alexandru Tatarciuc's user avatar
0 votes
0 answers
46 views

Angular DI can't resolve token for same class from different WEBPACK_IMPORTED_MODULE

I'm using ngx-mat-select-search and it's complaining about missing MatLegacySelect provider that is clearly provided. I started using a dynamic import when this started occuring if that helps. But ...
Novaterata's user avatar
  • 4,895
2 votes
3 answers
2k views

Recently started a new concept called Interceptor in Angular 17, but I got the error while practice

I tried to implement the interceptor concept in my angular demo project but I'm getting error on httpInterceptor line 7 i.e `export const httpInterceptor: HttpInterceptorFn = (req, next) => {` I'm ...
user25293681's user avatar
0 votes
1 answer
61 views

Which type of injector injects the ViewContainerRef or ElementRef?

I read several articles about the two types of injector hierarchies in Angular - the ElementInjector and the EnvironmentInjector hierarchies, and what type of dependencies they provide, and how when ...
atiyar's user avatar
  • 8,385
1 vote
1 answer
539 views

Angular inject Router into CanActivateFn to use in runInInjectionContext

I have a guard that needs to get something async and then decide with that value if a user needs to be redirected with the URLTree. The code itself is very simple: export const otapGuard: ...
YhEtesian's user avatar
1 vote
1 answer
601 views

Angular 17 Functional Resolver Unable to Inject Services Into Jest Test Case

Overview Hi there, I am in the process of migrating my Angular app from v14 to v17, and one of the tasks that comes with this is replacing the old deprecated Resolver classes with the new ResolverFn ...
IMeyers20's user avatar
  • 241
1 vote
1 answer
44 views

Unit Test case to mock Behavior Subject in Store

I have created a store to load address detail in behavior subject @Injectable({ providedIn: 'root' }) export class AddressStore { private subjectAddress = new BehaviorSubject<Address[]>([...
Ashok's user avatar
  • 311
2 votes
1 answer
261 views

Functional resolver with two injected services (Angular 15)

In my resolver, I am trying to inject two services, which uses response of one as input for next service call: export const addressResolver : ResolveFn<Address> = ( route: ...
Ashok's user avatar
  • 311
3 votes
2 answers
3k views

Angular standalone component and service constructor injection

I'm having problem injecting a service through standalone component's constructor. Service is defined as Injectable with provider set to root: @Injectable({ providedIn: 'root' }) export class ...
Jorgen's user avatar
  • 115

15 30 50 per page