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 の async init を 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' エラーは、fb のような (またはその他のタグ) が Facebook SDK によって iframe に置き換えられ、iframe に iframe でレンダリングされることを意図していない Web サイトが含まれていることを示唆しています。この同様の問題を solution で参照してください。

于 2013-04-08T11:36:44.987 に答える