簡體   English   中英

NullInjectorError: StaticInjectorError(AppModule)[Voter -> Number]:

[英]NullInjectorError: StaticInjectorError(AppModule)[Voter -> Number]:

我收到此錯誤。 我不知道為什么它要求我將我的選民模型注入“Number”,我什至不知道“Number”是什么,因為我的項目中沒有名為“Number”的組件或模型。

ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[Voter -> Number]: 
      StaticInjectorError(Platform: core)[Voter -> Number]: 
      NullInjectorError: No provider for Number!

這是我的 app.module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

// import { Voter } from './evoting/model.module';
import { EvotingModule } from './evoting/evoting.module';



@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    EvotingModule


  ],
  providers: [],

  bootstrap: [AppComponent]
})
export class AppModule { }

這是我的選民模塊

import { Injectable } from '@angular/core';
@Injectable({providedIn: 'root'},)
export class Voter{
    constructor(
        public id?: number,
        public name?: string,
        public vin?: number,
        public city?: string,
        public password?: string,
        // public formdata?: FormData

    ){

    }

    clear(){
        this.id = null;
        this.name = this.vin = this.city = null;
        // this.formdata = null;
        this.password = null;
    }
}

您可能錯過了在模塊中的 Providers 中添加服務,如下所示:

  providers: [
    PartnerAccountInfoService,
    yourServiceName
  ]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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