我正在为 rc5 的 angular2-jwt 文档苦苦挣扎
这是我的 NgModule
import { AuthHttp } from 'angular2-jwt';
@NgModule({
imports: [ BrowserModule,
routing,
HttpModule,
FormsModule,
],
declarations: [
AppComponent,
LoginComponent,
NavbarComponent,
DashboardComponent,
ModelsComponent
],
providers: [AuthGuard,
ModelService,
AuthHttp
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
这是我的服务
import { Injectable } from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
import { Model } from './model';
import { AuthHttp } from 'angular2-jwt';
import {Observable} from "rxjs/Rx";
@Injectable()
export class ModelService {
private _url = "http://127.0.0.1:8050/test/model";
constructor(private _http: Http,private _authHttp: AuthHttp){
//this.jwt = localStorage.getItem('id_token');
}
getPollModles(){
return Observable.interval(5000).switchMap(() => this._authHttp.get(this._url)).map(res => res.json());
}
}
如何让 angular2_jwt 与 rc5 一起使用?
当我将服务添加到构造函数时,我得到以下错误。
constructor(private route: ActivatedRoute,
public router: Router,
private modelService: ModelService)
core.umd.js:5995EXCEPTION: Uncaught (in promise): Error: Error in ./ModelsComponent class ModelsComponent_Host - inline template:0:0 caused by: No provider for AuthConfig!