【发布时间】:2016-10-02 05:37:43
【问题描述】:
我是 ionic2(和 angular2)的新手,我尝试在我的第一个应用程序中实现 auth0。 所以我跟着这个:https://auth0.com/docs/quickstart/hybrid/ionic2/no-api
我从 ionic2 网站上的“开始”开始,一切正常。 然后,我按照 auth0 快速入门中的所有步骤进行操作,但是当我执行“离子服务”时,我收到此错误:
0 883034 error Uncaught Invalid provider - only instances of Provider and Type are allowed, got: [object Object], http://localhost:8100/build/js/app.bundle.js, Line: 24470
我认为问题出在 app.ts 中,在 @App 提供者中:
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import {provide} from 'angular2/core';
import {Http} from 'angular2/http'
import {AuthHttp, AuthConfig} from 'angular2-jwt';
import {AuthService} from './services/auth/auth';
import {Type} from 'angular2/core';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
config: {},
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig(), http);
},
deps: [Http]
}),
AuthService
],
})
export class MyApp {
rootPage: any = TabsPage;
constructor(platform: Platform) {
platform.ready().then(() => {
StatusBar.styleDefault();
// When the app starts up, there might be a valid
// token in local storage. If there is, we should
// schedule an initial token refresh for when the
// token expires
this.auth.startupTokenRefresh();
});
}
}
谢谢帮助我!
【问题讨论】:
-
我有同样的问题,有什么帮助吗? :S