我想在angular2-jwt
我的ionic2
应用程序中使用它,我不断得到No provider for AuthConfig!
这是我的app.ts
:
import {AuthHttp, AuthConfig} from 'angular2-jwt';
import {Http} from 'angular2/http'
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig(), http);
},
deps: [Http]
}),
AuthHttp
]
})
我在我的login.ts
页面上使用它:
import {AuthHttp, AuthConfig} from 'angular2-jwt';
@Page({
templateUrl: 'build/pages/login/login.html',
directives: [IONIC_DIRECTIVES]
})
export class LoginPage {
constructor(private authHttp: AuthHttp){
}
}