没有 Facebook 的提供者(Ionic Native)
No provider for Facebook (Ionic Native)
ERROR Error: No provider for Facebook!
 at injectionError (core.es5.js:1231)
 at noProviderError (core.es5.js:1269)
 at ReflectiveInjector_.throwOrNull (core.es5.js:2770)
 at ReflectiveInjector.getByKeyDefault (core.es5.js:2809)
 at ReflectiveInjector.getByKey (core.es5.js:2741)
 at ReflectiveInjector.get (core.es5.js:2610)
 at AppModuleInjector.NgModuleInjector.get (core.es5.js:3578)
 at resolveDep (core.es5.js:11039)
 at createClass (core.es5.js:10903)
at createDirectiveInstance (core.es5.js:10723)
View_MyApp_Host_0 @ MyApp_Host.html:1
您需要在 AppModule
(app.module.ts
文件)中添加 Facebook
:
// ...
import { Facebook } from '@ionic-native/facebook';
@NgModule({
declarations: [...],
imports: [...],
bootstrap: [IonicApp],
entryComponents: [...],
providers: [
// ...
Facebook // <--- Here!
// ...
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule { }
所选答案适用于 Ionic3。对于 离子 4+:
在哪个 模块有使用FB登录的组件,添加:
import { Facebook } from '@ionic-native/facebook/ngx';
[注意/ngx]
并为该 @NgModule 添加提供程序
providers: [ Facebook, .... ]
ERROR Error: No provider for Facebook!
 at injectionError (core.es5.js:1231)
 at noProviderError (core.es5.js:1269)
 at ReflectiveInjector_.throwOrNull (core.es5.js:2770)
 at ReflectiveInjector.getByKeyDefault (core.es5.js:2809)
 at ReflectiveInjector.getByKey (core.es5.js:2741)
 at ReflectiveInjector.get (core.es5.js:2610)
 at AppModuleInjector.NgModuleInjector.get (core.es5.js:3578)
 at resolveDep (core.es5.js:11039)
 at createClass (core.es5.js:10903)
at createDirectiveInstance (core.es5.js:10723)
View_MyApp_Host_0 @ MyApp_Host.html:1
您需要在 AppModule
(app.module.ts
文件)中添加 Facebook
:
// ...
import { Facebook } from '@ionic-native/facebook';
@NgModule({
declarations: [...],
imports: [...],
bootstrap: [IonicApp],
entryComponents: [...],
providers: [
// ...
Facebook // <--- Here!
// ...
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule { }
所选答案适用于 Ionic3。对于 离子 4+: 在哪个 模块有使用FB登录的组件,添加:
import { Facebook } from '@ionic-native/facebook/ngx';
[注意/ngx]
并为该 @NgModule 添加提供程序
providers: [ Facebook, .... ]