angular 4错误:未捕获(承诺):错误:没有ConnectionBackend的提供程序!在注射Jsonp时 [英] angular 4 Error: Uncaught (in promise): Error: No provider for ConnectionBackend! while injecting Jsonp
本文介绍了angular 4错误:未捕获(承诺):错误:没有ConnectionBackend的提供程序!在注射Jsonp时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试注入Jsonp时,我看到此错误
When i am trying to inject Jsonp, i am seeing this error
异常:调用节点模块失败,并显示以下错误:错误:未捕获(承诺):错误:没有ConnectionBackend的提供程序!错误:没有ConnectionBackend的提供者!错误(本机)
Exception: Call to Node module failed with error: Error: Uncaught (in promise): Error: No provider for ConnectionBackend! Error: No provider for ConnectionBackend! at Error (native)
我的home.component.ts文件
import { NgModule, Component, Injectable } from '@angular/core';
import { HttpModule, JsonpModule, Jsonp, Response, URLSearchParams, Headers, RequestOptions } from '@angular/http';
@Component({
selector: 'home',
templateUrl: './home.component.html',
providers: [HttpModule, JsonpModule, Jsonp]
})
@Injectable()
export class HomeComponent {
public jsonp: Jsonp;
constructor(jsonp: Jsonp) {
this.jsonp = jsonp;
}
请帮助我解决此问题.
推荐答案
提供者
数组只能具有 Injectable
,不能具有 modules
providers
array can only have Injectable
not modules
providers: [HttpModule, JsonpModule, Jsonp]
应该是
providers: [Jsonp]
还要确保在 AppModule
这篇关于angular 4错误:未捕获(承诺):错误:没有ConnectionBackend的提供程序!在注射Jsonp时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文