没有Facebook的提供者(Ionic Native)

Par*_*ani 2 typescript ionic2 ionic-native ionic3 angular

错误错误:没有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
获得(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

seb*_*ras 7

您需要添加Facebook在你的AppModule(app.module.ts文件):

// ...
import { Facebook } from '@ionic-native/facebook';


@NgModule({
    declarations: [...],
    imports: [...],
    bootstrap: [IonicApp],
    entryComponents: [...],
    providers: [
        // ...
        Facebook // <--- Here!
        // ...
        { provide: ErrorHandler, useClass: IonicErrorHandler }
    ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)


Dee*_*mas 5

所选答案适用于 Ionic3。对于Ionic 4 +:在任何具有使用 FB 登录的组件 的模块中,添加:

import { Facebook } from '@ionic-native/facebook/ngx';
Run Code Online (Sandbox Code Playgroud)

[注意/ngx]

并添加该 @NgModule 的提供者

providers: [ Facebook, .... ]
Run Code Online (Sandbox Code Playgroud)

  • 今天的英雄。在 ionic 5 中,包是 @awesome-cordova-plugins/facebook/ngx (2认同)