Ionic3 staticInjectorError

时间:2018-05-09 08:09:33

标签: ionic3

我需要一些关于ionic3和firebase中staticinjector错误的帮助。

我的问题是在页面构造函数中使用AngularFireAuth。像这样;

constructor(private windowSvc: WindowService,
public navCtrl: NavController,
public navParams: NavParams,
private autSvc: AuthenticationService,
private userSvc: UserService,
private angAuth: AngularFireAuth)

当我在构造函数中使用angularfireAuth时,我总是收到此错误消息:

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[FirebaseApp -> InjectionToken FirebaseAppConfigToken]: 
  StaticInjectorError(Platform: core)[FirebaseApp -> InjectionToken FirebaseAppConfigToken]: 
    NullInjectorError: No provider for InjectionToken FirebaseAppConfigToken!
Error: StaticInjectorError(AppModule)[FirebaseApp -> InjectionToken FirebaseAppConfigToken]: 
  StaticInjectorError(Platform: core)[FirebaseApp -> InjectionToken FirebaseAppConfigToken]: 
    NullInjectorError: No provider for InjectionToken FirebaseAppConfigToken!
    at _NullInjector.get (core.js:1003)
    at resolveToken (core.js:1301)
    at tryResolveToken (core.js:1243)
    at StaticInjector.get (core.js:1111)
    at resolveToken (core.js:1301)
    at tryResolveToken (core.js:1243)
    at StaticInjector.get (core.js:1111)
    at resolveNgModuleDep (core.js:10896)
    at _callFactory (core.js:10960)
    at _createProviderInstance$1 (core.js:10910)
    at _NullInjector.get (core.js:1003)
    at resolveToken (core.js:1301)
    at tryResolveToken (core.js:1243)
    at StaticInjector.get (core.js:1111)
    at resolveToken (core.js:1301)
    at tryResolveToken (core.js:1243)
    at StaticInjector.get (core.js:1111)
    at resolveNgModuleDep (core.js:10896)
    at _callFactory (core.js:10960)
    at _createProviderInstance$1 (core.js:10910)
    at c (polyfills.js:3)
    at Object.reject (polyfills.js:3)
    at NavControllerBase._fireError (nav-controller-base.js:223)
    at NavControllerBase._failed (nav-controller-base.js:216)
    at nav-controller-base.js:263
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4760)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3
defaultErrorLogger @ core.js:1449

App.Module.ts:

@NgModule({
  imports: [
    BrMaskerModule,
    BrowserModule,
    IonicModule.forRoot(MyApp),
    AngularFireAuthModule, 
    AngularFireDatabaseModule
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    AuthenticationService,
    UserService,
    WindowService,
    AngularFireAuth
  ]
})

我该怎么做才能解决这个错误?

2 个答案:

答案 0 :(得分:0)



import { firebase } from 'firebase';

....
....
....
.

providers: [firebase]
....
....

Look your file u use ` import firebase from 'firebase'` like this. please change it 




答案 1 :(得分:0)

我解决了关于module.ts(不是app.module.ts)的问题。创建页面时,请不要使用模块。如果有页面模块,则会出现该错误