137 questions
1
vote
1
answer
41
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
49
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
62
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
102
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
463
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,
}
...
4
votes
2
answers
3k
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
50
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 ...
1
vote
1
answer
86
views
Troubleshooting NG0203 Error: Issues with Angular Library and HttpClient Injection in Production Build
I wasn't able to solve it. I'm counting on your help.
I have an Angular application and a library.
In the library, I have a service where I inject HttpClient. I set HttpClient as a provider in the ...
5
votes
2
answers
1k
views
How to access provider value in Angular 19
Using Angular SSR, I would like to access a server-side value in my app.component.
Here is my server-side route:
app.get('**', (req, res, next) => {
const { protocol, originalUrl, baseUrl, ...
3
votes
2
answers
117
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({ ...
1
vote
2
answers
304
views
How to inject a Service inside ApplicationConfig?
How to inject a Service inside ApplicationConfig?
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(appRoutes),
provideTransloco({
config: {
...
1
vote
0
answers
53
views
Using Injector.create() to dynamically create injector for embedded view is not working when parent injector is provided via parent property
I want to dynamically create the injector for embeddedView and for that purpose I use Injector.create() method:
const myInjector = Injector.create({
providers: [
{
...
1
vote
1
answer
46
views
Injecting a service in Angular using a Symbol does not work in Firefox
My Angular app works in Chrome.
export interface UserService {
me(): Observable<Response<User>>;
}
export const UserServiceRef = Symbol();
----
providers: [
{
provide: ...
0
votes
2
answers
233
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 ...
0
votes
0
answers
69
views
Why Angular provider is not detectedin standalone component?
I have a component, which I will build using my custom builder. This builder builds my component in ESM format.
My component code (which will be built) is a simple standalone component which imports ...