簡體   English   中英

錯誤:StaticInjectorError(AppModule)[global]:StaticInjectorError(Platform:core)[global]:NullInjectorError:沒有提供全局

[英]ERROR : StaticInjectorError(AppModule)[global]: StaticInjectorError(Platform: core)[global]: NullInjectorError: No provider for global

我打開了我的 ionic 項目,但在瀏覽器中沒有任何顯示。 我收到類似我的錯誤的錯誤

這是我在 app.module.ts 中的代碼

import { HttpClientModule } from "@angular/common/http";
import { HttpModule } from '@angular/http';
imports: [
  HttpClientModule,
  HttpModule ,
 ],
providers: [
  Clipboard,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
 ],
bootstrap: [AppComponent]
  })

有兩個可能的原因 1. 如果您在服務中使用 HttpClient,則需要在模塊文件中導入 HttpClientModule 並在導入數組中提及它。

import { HttpClientModule } from '@angular/common/http';

2) 如果您在服務中使用普通 Http,則需要在模塊文件中導入 HttpModule 並在導入數組中提及它。

import { HttpModule } from '@angular/http'

暫無
暫無

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

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