Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 未捕获(承诺中):错误:HttpService没有提供程序_Angular - Fatal编程技术网

Angular 未捕获(承诺中):错误:HttpService没有提供程序

Angular 未捕获(承诺中):错误:HttpService没有提供程序,angular,Angular,我是angular 4的新手,我非常感谢您对解决这个问题的帮助 如果有一个core.module正在被app.module使用。 为了支持jwt并将其连接到模拟后端,我正在尝试创建自己的HttpService 运行应用程序时,我遇到以下错误: 未捕获(承诺中):错误:HttpService没有提供程序] 代码: core.module.ts 从'@angular/http/testing'导入{MockBackend}; 从“../\u mocks/fake backend provider”

我是angular 4的新手,我非常感谢您对解决这个问题的帮助

如果有一个core.module正在被app.module使用。 为了支持jwt并将其连接到模拟后端,我正在尝试创建自己的HttpService

运行应用程序时,我遇到以下错误: 未捕获(承诺中):错误:HttpService没有提供程序]

代码:

core.module.ts

从'@angular/http/testing'导入{MockBackend};
从“../\u mocks/fake backend provider”导入{fakeBackendFactory,fakeBackendProvider}”;
从“../\u models/JWTRequestOptions.model”导入{JWTRequestOptions};
从“../\u guards/guest only.guard”导入{GuestOnlyGuard}”;
从“@angular/core”导入{NgModule,可选,SkipSelf};
从“@angular/common”导入{CommonModule};
从'@angular/router'导入{RouterModule};
从'@angular/Http'导入{HttpModule,Http,XHRBackend,ConnectionBackend,RequestOptions};
从'@ng bootstrap/ng bootstrap'导入{NgbModule};
从'@ngx translate/core'导入{TranslateModule};
从“../shell/shell.component”导入{ShellComponent};
从“../shell/header/header.component”导入{HeaderComponent};
从“../\u services/authentication.service”导入{AuthenticationService};
从“../\u guards/authentication.guard”导入{AuthenticationGuard};
从“../\u services/i18n.service”导入{I18nService};
从“../\u services/http.service”导入{HttpService};
从“../\u services/http cache.service”导入{HttpCacheService};
从“app/_services/credantials.service”导入{CredantialsService};
从“app/_services/storage.service”导入{StorageService};
从“app/_services/validators.service”导入{ValidatorsService};
从“app/_services/formvalidators.service”导入{FormValidatorsService};
导出函数createHttpService(后端:ConnectionBackend,
jwtRequestOptions:jwtRequestOptions,
httpCacheService:httpCacheService,
Credantials服务:Credantials服务){
返回新的HttpService(后端、jwtRequestOptions、httpCacheService、credantialsService);
}
@NGD模块({
进口:[
公共模块,
HttpModule,
TranslateModule,
路由模块,
NgbModule.forRoot()
],
出口:[
头部组件
],
声明:[
外壳组件,
头部组件
],
供应商:[
认证服务,
AuthenticationGuard,
客房警卫,
I18N服务,
火葬服务,
HttpCacheService,
存储服务,
验证器服务,
FormValidator服务,
模拟后端,
伪造后端提供者,
{
提供:Http,
deps:[XHRBackend,RequestOptions,HttpCacheService,CredantialsService,StorageService],
useFactory:createHttpService
}
]
})
导出类核心模块{
构造函数(@Optional()@SkipSelf()父模块:CoreModule){
//进口保护
if(父模块){
抛出新错误(`${parentModule}已加载。仅在AppModule中导入核心模块。`);
}
}

}
它与原始http服务一起工作吗?在哪里注入它?不,它与原始http服务器不工作。注入哪个部分?您没有显示注入它的位置您没有将HttpService包括到提供程序数组中添加它,就像
providers:[HttpService]