[英]Error: Uncaught (in promise): NullInjectorError: R3InjectorError(GestionGeneralModule)
Hello I am trying to list a table with the ResumenService service but I get the following error您好,我正在尝试使用 ResumenService 服务列出一个表,但出现以下错误
Error: Uncaught (in promise): NullInjectorError: R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]:错误:未捕获(承诺):NullInjectorError:R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]:
NullInjectorError: No provider for ResumenService: NullInjectorError: R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]: NullInjectorError: ResumenService 没有提供者: NullInjectorError: R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]:
NullInjectorError: No provider for ResumenService! NullInjectorError:没有 ResumenService 的提供者!
general.module.ts通用模块.ts
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { GeneralRoutingModule } from './general-routing.module';
import { GeneralService } from './services/general.service';
import { ResumenService } from './services/resumen.service';
@NgModule({
declarations: [],
imports: [
GeneralRoutingModule,
HttpClientModule
],
providers: [
GeneralService,
ResumenService,
]
})
export class GeneralModule { }
resumen.service.ts恢复服务.ts
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { ConvertObjectToGetParams, IDataGridPageRequest } from "shared";
import { CORE_FUNCTIONS, IPaginationResponse, IServerResponse } from '@app/core';
import { environment } from "src/environments/environment";
@Injectable()
export class ResumenService {
private url = `${environment.baseUrlAPI}/api/resumen`;
constructor(
private http: HttpClient
) { }
ListarSolDocumentosControl = (idEvento: number) => {
const params = ConvertObjectToGetParams({ idEvento });
return this.http.get<IServerResponse<any[]>>(
`${this.url}/SolDocumentosControl`, { params }
);
};
guardarResumen = (idEvento: number, data: any, archivo: any) => {
const formData = CORE_FUNCTIONS.jsonToFormData({
...data,
archivo
});
return this.http.post<IServerResponse<any[]>>(
`${this.url}/DocumentosControl/${idEvento}`, formData, { headers: { 'Content-Type': 'Upload-File' } }
);
}
}
You are using ResumenService
into GestionGeneralSolState in GestionGeneralModule, but you only provide this service in GeneralModule.您在ResumenService
ResumenService 用于 GestionGeneralSolState,但您仅在 GeneralModule 中提供此服务。 Please double check in GestionGeneralModule whether you have declared ResumenService or not请仔细检查 GestionGeneralModule 是否已声明 ResumenService
In ResumenService replace your @Injectable
for this:在 ResumenService 中替换你的@Injectable
:
@Injectable({
providedIn: 'root' // It will inject this provider at the root level of the application so it can be accessed anywhere.
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.