AngularJS: DI Error - No module: $facebook, why is

2019-08-21 05:57发布

I've been trying to learn AngularJS by doing small exercises. At this point, I'd like to use the Facebook SDK and found a few ng services and I've been trying them all.

The following one, provided as "angular-facebook", returns in the console:

Error: No module: $facebook

angular.module('myApp', ['ngResource', 'facebook'])
.config(['$facebook', function($facebookProvider) {
}])

I've also tried the following (and other many ways):

Error: No module: $facebook

angular.module('myApp', ['ngResource', 'facebook'])
.config(['$facebookProvider', function($facebookProvider) {
}])

The angular-facebook.js can be found at (I'm not loading directly from here, I've got it in my local):

https://github.com/rafaelalmeidaerthalhermano/angular-facebook/blob/master/angular-facebook.js

I'd like to understand why isn't this working ? I've been trying to solve this issue for hours without success.

Thanks for looking!

/***** PROGRESS *****************/

The user JQuery Guru gave some advice and I can see that the module loads. For my specific needs, I guess the only way is, to create a separate module where the facebookProvider is initialized and then, then inject to the main/other module.

The issue now is that the FB.login(fn, permissions) is not working for the second parameter. The FB Popup is not requesting the right permissions. I can clearly see, in the source code that there's a fn handler that uses the right parameters / parameters being set correctly. I'd like to understand why isn't this working ? Not sure if I should create a new question in SO

This is the code I've got so far:

http://jsbin.com/IteY/1/

This is where I'm setting the permissions list:

facebook.login(function(response) {
    console.log(response);
}, {scope: 'email,user_likes'});

by doing console.log in the fn handler for login(), I get the fn function(response){ ... } and the {scope: 'email,user_likes'}

***** PROGRESS******

I found some other users reporting the same issue using the FB SDK here in SO. I tried the tip to use "perms" instead of "scope", but I get:

OAuth2 specification states that 'perms' should now be called 'scope'. Please update.

  • Not appearing to be the problem. This also shows that the param is being send there. Go wonder why's not working ?! I've cleaned cache too

I think this issue is related with Facebook API and not the angular module ? I may be wrong, so I've reported here ( Angular + Facebook JS SDK login: Not requesting my permissions )

0条回答
登录 后发表回答