zyra / ngx-facebook

Angular TypeScript Wrapper for Facebook SDK
http://zyra.github.io/ngx-facebook/
MIT License
209 stars 71 forks source link

Angular 4 and ngx-facebook #113

Open Dpavlova opened 6 years ago

Dpavlova commented 6 years ago

Hello, I am building an angular4 app and I want to display a facebook page with the like button.

The problem is that the facebook is called into the constructor and on each change of the pages of my website, the facebook page dissapears. My question is, is there a way to make the facebook run on init instead of adding it into the constructor?

ihadeed commented 6 years ago

The best thing to do is to inject the Facebook provider in the constructor of your app's main component. This ensures that Facebook's SDK is always initialized when your app is running. If you are just using the components (HTML tags), then you only need to inject the service once.

joscmw95 commented 6 years ago

probably same as https://github.com/zyra/ngx-facebook/issues/127#issuecomment-381209599