gpt4 book ai didi

angular - "@angular/http/index has no exported member of HTTP_PROVIDERS"

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

依赖关系

enter image description here

ma​​in.ts 文件

enter image description here

我想导入 HTTP_PROVIDERS 但它给我的错误是

"@angular/http/index has no exported member of HTTP_PROVIDERS"

我附上了package.json 和main.ts 文件的图片

最佳答案

HTTP-PROVIDERS 不再使用。将 HttpModule 导入您的 ngModule 并将其添加到您的导入中。

import { HttpModule } from '@angular/http';

@NgModule({
imports: [
...
HttpModule,
],
declarations: [...],
bootstrap: [ .. ],
providers: [ ... ],
})

我建议你总是查看 angular.io 页面以获取当前信息。例如,here描述了 Http 的用法和所需的一切:)

在要使用 http 的服务中,导入 Http 并将其注入(inject)到构造函数中:

import { Http } from '@angular/http';

// ...

constructor(private http: Http) { }

关于angular - "@angular/http/index has no exported member of HTTP_PROVIDERS",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42271146/

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