angular - 为什么我收到此错误:StaticInjectorError(AppModule)[VideosService -> Http
问题描述
我收到此错误:
core.js:1449 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[VideosService -> Ht**strong text**tp]:
StaticInjectorError(Platform: core)[VideosService -> Http]:
NullInjectorError: No provider for Http!
Error: StaticInjectorError(AppModule)[VideosService -> Http]:
StaticInjectorError(Platform: core)[VideosService -> Http]:
NullInjectorError: No provider for Http!
解决方案
您可能必须导入HttpModule
app.module.ts
// main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, HttpModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
推荐阅读
- selenium - 很抱歉,您的计算机或网络在使用 Selenium 在自动测试环境中加载 Google API 时可能会发送自动查询错误
- c# - 有没有办法给网站信息,并得到一个情节?
- node.js - 无法在 Node.js 13.6 中导入 @google/pubsub 和其他 @google npm 模块
- android - Kotlin 中硬关键字和软关键字的区别
- c++ - 如何在 C++ 中使用 OpenSSL 库实现 EVP_aes_256_cbc?
- machine-learning - 我应该为回归问题进行归一化还是标准化?
- c# - 如何将文件从一个 FTP 移动到另一个 FTP?
- module - 如何在编译时以程序方式构造属性的值?
- javascript - 当我尝试使用 RDB 时发生 Firebase 数据库 URL 错误
- python - 无法在仅 tensorflow CPU 安装上加载动态库“cudart64_101.dll”