0

我的 HTML 中有这个

<div class="container" ng-controller="MyControl">
   ....(some html removed)....
   <fb-like data-href="...." data-send="false" data-layout="button_count" data-width="120" data-show-faces="false" data-font="verdana"></fb-like>

在我的 JS 中,我没有将 Facebook 异步初始化放在 MyControl 中,而是放在其他一些控件中。并在文档准备好时加载 Facebook 脚本。

function SomeOtherControl($scope,$rootScope) {
    ...(some code removed)....
window.fbAsyncInit = function() {
  // init the FB JS SDK
  FB.init({
    appId      : '...', // App ID from the App Dashboard
    channelUrl : '...', // Channel File for x-domain communication
    status     : false, // check the login status upon init?
    cookie     : true, // set sessions cookies to allow your server to access the session?
    xfbml      : true  // parse XFBML tags on this page?
  });
  FbLogin($scope,true);
  $rootScope.lastFbLogin = new Date();
  $rootScope.$apply('lastFbLogin')
};
angular.element(document).ready(function(){
    (function(d, debug){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
       ref.parentNode.insertBefore(js, ref);
    }(document, /*debug*/ false));
})

lastFbLogin 现在是空的

$rootScope.$watch('lastFbLogin',function(newVal,oldVal){
    if (!!newVal) {
    }
});
4

1 回答 1

1

我认为这与 Angular 无关。'forbidden by X-Frame Options' 错误表明 Facebook SDK 将 fb-like(或其他标签)替换为 iframe,并且 iframe 包含不打算在 iframe 中呈现的网站。使用解决方案查看此类似问题

于 2013-04-08T11:36:44.987 回答