Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook SDK和AngularJS手动引导_Facebook_Angularjs - Fatal编程技术网

Facebook SDK和AngularJS手动引导

Facebook SDK和AngularJS手动引导,facebook,angularjs,Facebook,Angularjs,我需要在Angular之前加载FB sdk,这样对sdk的任何调用都可以工作。 我试着在FB init代码中手动引导,但它不起作用 我没有错误消息,但似乎引导没有发生: var myApp = angular.module('myApp', ['ngRoute', 'database', ..........]) .config(function($routeProvider) { ....... }) .run(['$rootScope', func

我需要在Angular之前加载FB sdk,这样对sdk的任何调用都可以工作。 我试着在FB init代码中手动引导,但它不起作用

我没有错误消息,但似乎引导没有发生:

var myApp = angular.module('myApp', ['ngRoute', 'database', ..........])

    .config(function($routeProvider) {
        .......
    })

    .run(['$rootScope', function($scope) {


        //Facebook load
        window.fbAsyncInit = function() {
            // init the FB JS SDK
            Parse.FacebookUtils.init({
                appId      : 'XXXXXXXXXXXXX',
                //status     : true,
                cookie     : true,
                xfbml      : true
            });
                angular.bootstrap(document.getElementById("loadAngular"), ['myApp']); // Manual Bootstrap

        };


        // Load the SDK asynchronously
        (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/all.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    }]);
关于html,我有:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body id="loadAngular">

<div id="fb-root"></div>
<div ng-controller="logController">
.....

.....

如果您有引导未发生的线索,请告诉。

同一个指令可用于检查以下url:

试试这个

var myApp = angular.module('myApp', [...]);
myApp.config(...);
myApp.run(...);

//Facebook load
window.fbAsyncInit = function() {
    // init the FB JS SDK
    Parse.FacebookUtils.init({
        appId      : 'XXXXXXXXXXXXX',
        //status     : true,
        cookie     : true,
        xfbml      : true
    });
    angular.bootstrap(document, ['myApp']);
};

// Load the SDK asynchronously
(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/all.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

你不能在run函数内部引导应用程序,这是另一种方式-引导触发run函数,因此你必须将FB加载脚本完全移出
angular。module
Part这应该很有帮助: