0
I’m working with Ionic 3 and I’m using some of your native services, like logging in with facebook. Everything works perfectly, my problem is in something I’m trying to do to organize my code more.
When I use the facebook plugin by page app.module
everything works perfectly. However, for the sake of organization, I decided to move it to the floor of the only page that actually uses it.
Example:
I have the following pages abertura.ts
and abertura.module.ts
When I try to move the facebook plugin import from page app.module.ts
to the page abertura.module.ts
, receive the following error message:
ERROR Error: Uncaught (in Promise): Error: Staticinjectorerror[Facebook]: Staticinjectorerror[Facebook]: Nullinjectorerror: No Provider for Facebook! Error: Staticinjectorerror[Facebook]: Staticinjectorerror[Facebook]: Nullinjectorerror: No Provider for Facebook!
Well, basically he’s saying that it wasn’t possible to inject Facebook into Previovider. But because I can’t do it on the specific page that uses it?
My code for the page abertura.module.ts
:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { AberturaPage } from './abertura';
import { Facebook } from '@ionic-native/facebook';
import { GooglePlus } from '@ionic-native/google-plus';
import { LinkedIn } from '@ionic-native/linkedin';
@NgModule({
declarations: [
AberturaPage,
],
imports: [
IonicPageModule.forChild(AberturaPage)
],
providers: [
LinkedIn,
Facebook,
GooglePlus
]
})
export class AberturaPageModule {}
put your app.module.ts -- however, Ionic-Active README explicitly tells you to put the Native-modules to be provided by app.module.ts
– MoshMage
You can share this link for me to look at?
– alan
https://ionicframework.com/docs/native/facebook/#installation < second point
– MoshMage
It really says that. But it doesn’t make it clear whether or not I can add to the page module. In my view, it makes the code much cleaner. For me, the app.module should be for multi-page shared functionality only. But I’ll leave it at that for now. Anyway it was worth! ;)
– alan