Angularjs Facebook登录:无法读取属性'appendChild'为null [英] Angularjs Facebook Login: Cannot read property 'appendChild' of null
问题描述
通常我在加载页面时收到以下错误:
fb-rootdiv尚未创建,自动创建
无法读取属性appendChild为null
当我收到此错误时,Facebook登录弹出窗口为空或空白或无法登录。
我的角模块依赖关系如下:
angular.module('myApp',['ngResource','ngRoute','facebook' 'restangular','LocalStorageModule'])
我的index.html:
< html> < HEAD> .. ..< script src =index.js>< / script> < script src =assets / js / default.js>< / script>< / head>< body ng-view>< / body>< / html>
> ng-view 标签在< body>
ngRoute组织身体本身的内容,但Facebook js sdk试图控制'fb -root'div在body下。
解决方案是将ng-view移动到body下的内部div,并可选择创建fb-root div:
< html> < HEAD> < script src =index.js>< / script> < script src =assets / js / default.js>< / script>< / head> <身体GT; < div id =fb-root>< / div> < divng-view> < / div>< / body>< / html>
I am using angular-facebook module for adding Facebook Login capability to my application.
Generally I get the following error while loading the page:
The "fb-root" div has not been created, auto-creating
Cannot read property 'appendChild' of null
When I get this error the facebook login popup comes empty/blank or unable to login.
My angular module dependencies are below:
angular.module('myApp', ['ngResource', 'ngRoute', 'facebook', 'restangular', 'LocalStorageModule'])
My index.html:
<html>
<head>
..
..
<script src="index.js"></script>
<script src="assets/js/default.js"></script>
</head>
<body ng-view>
</body>
</html>
The problem occurs because of ng-view
tag in <body>
ngRoute organizes the content of body itself but facebook js sdk tries to control 'fb-root' div under body.
The solution is to move ng-view to an inner div under body and create a fb-root div optionally:
<html>
<head>
<script src="index.js"></script>
<script src="assets/js/default.js"></script>
</head>
<body>
<div id="fb-root"></div>
<div ng-view>
</div>
</body>
</html>
这篇关于Angularjs Facebook登录:无法读取属性'appendChild'为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!