如果我创建这样的文件(auth.module.ts):
import { NgModule } from '@angular/core';
import { Http, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt';
export function authHttpServiceFactory(http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig(), http, options);
}
@NgModule({
providers: [
{
provide: AuthHttp,
useFactory: authHttpServiceFactory,
deps: [Http, RequestOptions]
}
]
})
export class AuthModule {}
并在app.module.ts
中声明/导入它import {AuthModule} from "./services/auth.module";
@NgModule({
declarations: [
AppComponent,
...
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
...
AuthModule
],
providers: [
...
],
bootstrap: [AppComponent]
})
我如何从我的服务中获得AuthHttp提供商?
谢谢!
(如果需要更多上下文here)