我試圖通過ngFacebook設置登錄,但無法登錄到Facebook。調用'$ facebook.log()'後,我甚至無法獲取任何控制檯日誌。無法在angularjs應用上通過ngFacebook登錄Facebook
我的角度應用:
'use strict';
angular
.module('fmcFrontendApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ngFacebook'
])
.config(function ($facebookProvider) {
$facebookProvider.setAppId('///////////');
$facebookProvider.setCustomInit({
version: 'v2.2',
channelUrl : '/index.html',
xfbml : true
});
$facebookProvider.setPermissions('email, public_profile');
})
.run(function() {
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
})
.controller('fbCtrl', [ '$facebook', function($facebook) {
var self = this;
self.isLoggedIn = false;
self.login = function() {
console.log('hello')
$facebook.login().then(function() {
console.log("Please see me")
refresh();
});
}
function refresh() {
$facebook.api("/me").then(
function(response) {
console.log(response);
self.welcomeMsg = "Welcome " + response.name
self.isLoggedIn = true
},
function(err) {
self.welcomeMsg = "Please log in";
});
}
refresh();
}]);
及相關角元素:
<button id="fb-login" type="button" ng-click="fbCtrl.login()" ng-hide="fbCtrl.isLoggedIn" class="btn btn-default navbar-btn"> Login </button>
<div id="fb-root"></div>
任何幫助,任何人都可以給將不勝感激!我真的在絞盡腦汁,無法弄清楚發生了什麼事情!