gpt4 book ai didi

angular2 导入 HTTP_PROVIDERS 错误

转载 作者:太空狗 更新时间:2023-10-29 17:42:57 25 4
gpt4 key购买 nike

angular2 导入 HTTP_PROVIDERS

错误信息>>@angular/http/index"' 没有导出成员 'HTTP_PROVIDERS'。

import { Component } from '@angular/core';
import {NoticeService} from './products/product.service';
import {HTTP_PROVIDERS} from '@angular/http';
import 'rxjs/Rx';

@Component({
selector: 'my-app',
template: `
<h1>Hello {{name}}</h1>
<pm-products></pm-products>
`,
providers: [NoticeService, HTTP_PROVIDERS]
})

最佳答案

您不再需要 HTTP_PROVIDERS(已弃用)。改为导入 http 模块。

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

import { AppComponent } from './app.component';

@NgModule({
imports: [
BrowserModule,
HttpModule
],
declarations: [AppComponent],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule { }

关于angular2 导入 HTTP_PROVIDERS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42239197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com