145 questions
0
votes
1
answer
105
views
Angular 19 ApplicationConfig use Configuration in factory
In GitOp I want to replace config.json for each environment and with this internal app I want to keep it as simple as possible (e.g. no ngrx)
My problem is that config.json is loaded in a ...
0
votes
1
answer
128
views
How to pass a default value with @Optional in Angular 20?
In Angular 20, how can we inject an optional InjectionToken with a default value?
In Angular <20, I used to do it as follows:
constructor(@Optional@Inject(FOO) private foo = true){}
1
vote
2
answers
1k
views
How to use new Angular 20 inject syntax with
I'm using @Inject(String) to enable giving config at the instantiation of my service.
Here's the code:
const httpLoaderFactory: (http: HttpClient) => TranslateHttpLoader = (http: HttpClient) =>
...
0
votes
0
answers
17
views
How could mimic the module experience with Angular standalone components?
Since it looks like the modules in Angular are near the end of their life, and stand-alone components are the future, how can we provide dependencies in the same way as when a module is used?
With ...
0
votes
2
answers
238
views
How can I inject an Angular service into a custom class?
I have this custom class called SortState that represents sorting and paging on a table of records. Now I want to make that class talk to a service that displays a loading indicator. Apparently you ...
1
vote
1
answer
106
views
Angular Firebase Error: "NullInjectorError: No provider for Firestore2!" in Standalone Component
I'm working on an Angular standalone component using Firebase, and I'm encountering the following error:
ERROR NullInjectorError: R3InjectorError(Standalone[_AppComponent])[_FirebaseService -> ...
1
vote
1
answer
52
views
Functional style interceptors - How to provide them with dependencies
Imagine the situation where you provide any lib to client. Simple scenario, spinner interceptor which needs spinner service.
In old way it was possible to:
providers: [
{
provide: ...
1
vote
2
answers
309
views
Angular standalone:chain multiple functions in provideAppInitializer
In my Angular application (version 19), I have a provideAppInitializer like this:
export const appConfig: ApplicationConfig = {
providers: [
...
provideAppInitializer(intializeAppFn),
...
1
vote
1
answer
102
views
Error NG2003: No suitable injection token for parameter 'exportAsService' – ngx-export-as issue in Angular component reuse [closed]
I'm working on an Angular project and using the ngx-export-as package, which was already installed and working fine in some of my components.
However, when I tried to use the same ExportAsService in a ...
1
vote
1
answer
55
views
Restructuring a super call in a constructor to use the 'this'
I have the following service:
import {
ENVIRONMENT_TOKEN
} from '@reg/environment/domain'
@Injectable({ providedIn: 'root' })
export class RegStore extends ImmutableStore<TRegState> {
#env =...
2
votes
1
answer
114
views
How to provide a HostAttributeToken in Angular tests?
I recently discovered the HostAttributeToken in Angular (see docs) to provide static attributes for a component.
The following example works fine:
import { Component, HostAttributeToken, inject } from ...
0
votes
1
answer
146
views
NullInjectorError: R3InjectorError
I'm working in a personal project, using angular, but I receive the following error all the time:
NullInjectorError: R3InjectorError(Environment Injector)[_HttpClient->_HttpClient]: ...
2
votes
1
answer
621
views
convert APP_INITIALIZER code to newer provideAppInitializer syntax
I have a piece of code from an angular application like below,
{
provide: APP_INITIALIZER,
deps: [...config.mockApi.services],
useFactory: () => (): any => null,
multi: true,
}
...
5
votes
2
answers
5k
views
Angular 19 Standalone Component Error: "No provider for _HttpClient" Despite HttpClientModule Imported
I am working on an Angular standalone application and encountering the following error when using HttpClient in my DataService:
ERROR Error [NullInjectorError]: R3InjectorError(Standalone[...
1
vote
1
answer
72
views
Angular DI for standalone components with importing module on parent component and child component (NullInjectorError: R3InjectorError)
Given the following structure:
a parent standalone component named AppComponent
a child standalone component called TableComponent, which should be a wrapper for a generic table
TableComponent ...