简体   繁体   English

错误:未捕获(承诺中):NullInjectorError:R3InjectorError(GestionGeneralModule)

[英]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.

相关问题 错误:未捕获(承诺):NullInjectorError:R3InjectorError(AppModule)[baseURL] - Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[baseURL] 错误:未捕获(承诺):NullInjectorError:R3InjectorError(AppModule)Angular 13 - Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule) Angular 13 未捕获(承诺):NullInjectorError: R3InjectorError(AppModule)[FormBuilder -&gt; FormBuilder -&gt; FormBuilder] - Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[FormBuilder -> FormBuilder -> FormBuilder] 错误错误:未捕获(承诺):NullInjectorError:R3InjectorError(AppModule)[NavbarComponent - &gt; NavbarComponent - ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[NavbarComponent -> NavbarComponent 错误 NullInjectorError:R3InjectorError(AppModule) - ERROR NullInjectorError: R3InjectorError(AppModule) Angular 14 - 未捕获(承诺):NullInjectorError:R3InjectorError(Standalone [z])[s -&gt; s -&gt; s]: - Angular 14 - Uncaught (in promise): NullInjectorError: R3InjectorError(Standalone[z])[s -> s -> s]: 错误:NullInjectorError:R3InjectorError(AuthorModule)[ScrollbarHelper -&gt; ScrollbarHelper -&gt; ScrollbarHelper -&gt; ScrollbarHelper]: - Error: NullInjectorError: R3InjectorError(AuthorModule)[ScrollbarHelper -> ScrollbarHelper -> ScrollbarHelper -> ScrollbarHelper]: 错误 NullInjectorError:R3InjectorError(AppModule)[MessageService -&gt; MessageService -&gt; MessageService]: - ERROR NullInjectorError: R3InjectorError(AppModule)[MessageService -> MessageService -> MessageService]: 错误 NullInjectorError: R3InjectorError(n)[_0 -&gt; _0 -&gt; _0]: NullInjectorError: No provider for _0! --- 使用 Angular MatDialog 时 - ERROR NullInjectorError: R3InjectorError(n)[_0 -> _0 -> _0]: NullInjectorError: No provider for _0! --- When using Angular MatDialog 错误 NullInjectorError:R3InjectorError(AppModule)[NgbDropdown -> NgbDropdown -> NgbDropdown]:NullInjectorError:NgbDropdown 没有提供者 - ERROR NullInjectorError: R3InjectorError(AppModule)[NgbDropdown -> NgbDropdown -> NgbDropdown]: NullInjectorError: No provider for NgbDropdown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM