Angular 2 - 没有 Jsonp 的提供者

标签 angular

获取错误:

inline template:16:8 caused by: No provider for Jsonp!
ORIGINAL EXCEPTION: No provider for Jsonp!

我将“HttpModule”直接导入组件所属的模块中。

最佳答案

您需要导入并声明 JsonpModule,如下所示,

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

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

关于Angular 2 - 没有 Jsonp 的提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39473917/

相关文章:

angular - 如何通过 @Input() 将父组件传递到 Angular 7 中的子组件

html - CSS 转换出现不需要的行为

javascript - Angular js 到 Angular 5 迁移

c# - 如何使用 Angular 和 ASP.Net Core 转换字节数组 [] 中的文件并存储在数据库中?

angular - 如何在 Angular 5 中更改 ng-template 变量

angular - 如何使用 ng-sidebar 让 SidebarModule 在菜单按钮上推送内容?

javascript - 将 jQuery 插件与 Angular 5 (Typescript) 一起使用失败

angular - 如何将方法 "getFreeDragPosition"用于 Angular 8 CdkDrag?

Angular 6 使用 Http Interceptor 和配置服务

angular - Angular 模板中的可重用片段