簡體   English   中英

錯誤:未捕獲(承諾中):NullInjectorError:R3InjectorError(GestionGeneralModule)

[英]Error: Uncaught (in promise): NullInjectorError: R3InjectorError(GestionGeneralModule)

您好,我正在嘗試使用 ResumenService 服務列出一個表,但出現以下錯誤

錯誤:未捕獲(承諾):NullInjectorError:R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]:
NullInjectorError: ResumenService 沒有提供者: NullInjectorError: R3InjectorError(GestionGeneralModule)[NgxsFeatureModule -> GestionGeneralSolState -> ResumenService -> ResumenService -> ResumenService -> ResumenService -> ResumenService]:
NullInjectorError:沒有 ResumenService 的提供者!

通用模塊.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 { }

恢復服務.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' } }
        );
    }
}

您在ResumenService ResumenService 用於 GestionGeneralSolState,但您僅在 GeneralModule 中提供此服務。 請仔細檢查 GestionGeneralModule 是否已聲明 ResumenService

在 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM