how to properly inject Facebook JavaScript SDK to AngularJS controllers?

后端 未结 5 1805
一整个雨季
一整个雨季 2021-02-02 14:01

I\'m new to AnuglarJS and already built a small web-app with it, I would like to use the Facebook JavaScript SDK with it, but using best practices (dependency injecting to contr

5条回答
  •  广开言路
    2021-02-02 15:04

    The only way that works is including the the sdk in your index page in the old way.

    Because I have implemented the same solution from @blesh or extended version from @elviejo, both of them has a problem if we have a function which is called when the controller is invoked, the chance that FB is not initialized is very high and this will make the call failed while calling a function from undefined :)

    Hope this will help others avoiding headache with this.

提交回复
热议问题