依賴「@角/ HTTP /索引具有HTTP_PROVIDERS沒有出口成員」
main.ts文件
我想導入HTTP_PROVIDERS
但是給我的錯誤,
「@角/ HTTP /索引具有HTTP_PROVIDERS沒有出口構件」
我已附加的package.json的圖像和main.ts文件。
依賴「@角/ HTTP /索引具有HTTP_PROVIDERS沒有出口成員」
main.ts文件
我想導入HTTP_PROVIDERS
但是給我的錯誤,
「@角/ HTTP /索引具有HTTP_PROVIDERS沒有出口構件」
我已附加的package.json的圖像和main.ts文件。
HTTP-PROVIDERS
不再使用。改爲將HttpModule
導入您的ngModule
,並將其添加到您的導入。
import { HttpModule } from '@angular/http';
@NgModule({
imports: [
...
HttpModule,
],
declarations: [...],
bootstrap: [ .. ],
providers: [ ... ],
})
我建議你總是檢查angular.io頁面的當前信息。例如,HTTP的here使用而這被描述:)
在要使用HTTP服務所需要的一切,您導入Http
,並在構造函數注入它:
import { Http } from '@angular/http';
// ...
constructor(private http: Http) { }
你主模塊應導入HttpModule
,其中包含HTTP提供程序。這是最近的做法。
import { HttpModule } from '@angular/http';
@NgModule({
declarations: [],
imports: [
// ...,
HttpModule,
],
providers: [],
})
export class AppModule{
}
然後我應該使用哪個供應商爲HttpServices @ mathias247 –
只是添加,有時會發生錯字錯誤。 其具體爲HttpModule不是HTTPModule或HTTPmodule或其他。
然後我應該使用哪個供應商爲HttpServices @ AJT_82 –
該HttpModule包括:) :)我的答案也更新了一點。檢查我提供的鏈接,它有你需要在你的應用程序中使用Http的所有信息:) – Alex
非常感謝@ AJT_82 –