gpt4 book ai didi

Angular 4,httpClient 和 HttpClientModule 的区别

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

在这篇文章中here和其他人:看起来您需要在 app.module.ts 中导入 HttpClientModule 并在 app.component.ts 中导入 HttpClient 才能发出 http 请求。为什么?它们是如何工作的?

最佳答案

简单来说,

您可以将 HttpClientModule 称为作为 Angular 核心部分的“功能包”。在这个“功能包”中,您还有许多其他小功能,如 HttpClient(在 Angular 语言中,它是“服务”)、拦截器等。

为了使用这些“功能”,您需要在主模块(在您的例子中是 Angular 的 AppModule)中导入“功能包”,这样您就可以访问 HttpClient 和许多其他功能工作组件中的服务。

一行:

HttpClient is a angular service bundled inside HttpClientModule.

关于Angular 4,httpClient 和 HttpClientModule 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48124136/

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