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) {
}
});