gpt4 book ai didi

javascript - 按钮未在 AngularJs 中显示

转载 作者:行者123 更新时间:2023-11-30 16:43:14 25 4
gpt4 key购买 nike

我在后端使用 Django-rest 编写了前端 Facebook 登录代码以进行验证。但是,我的 HTML 文件中的按钮属性没有显示这是 AngularJS 中我的文件(HTML)的代码

<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div id="fb-root">
</div>

<script>
//facebook here
//***************************************************
window.fbAsyncInit = function() {
FB.init({
appId : 'Not inserted app id here for security reasons',
status : true,
xfbml : true
});
};

(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'));
</ script>

<button ng-click="login_fb()">Login with facebook</button>
<script>
angular.module("myApp").controller("UserCtrl",
['$scope','$location', 'Facebook',
function($scope, $location, Facebook /*we will write this factory next*/){

$scope.login_fb = function(){
Facebook.login().then(function(response){
//this is where we'll contact backend. for now just log response
console.log(response);
});
}
}]);
</ script>
<script>
angular.module("myApp").factory('Facebook',
["$q", "$window", "$rootScope",
function($q, $window, $rootScope) {

// since we are resolving a thirdparty response,
// we need to do so in $apply
var resolve = function(errval, retval, deferred) {
$rootScope.$apply(function() {
if (errval) {
deferred.reject(errval);
} else {
retval.connected = true;
deferred.resolve(retval);
}
});
}

var _login = function(){
var deferred = $q.defer();
//first check if we already have logged in
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app
console.log("fb user already logged in");
deferred.resolve(response);
} else {
// the user is logged in to Facebook,
// but has not authenticated your app
FB.login(function(response){
if(response.authResponse){
console.log("fb user logged in");
resolve(null, response, deferred);
}else{
console.log("fb user could not log in");
resolve(response.error, null, deferred);
}
});
}
});

return deferred.promise;
}

return{
login: _login,
};
}]);
</ script>

</body>
</html>

有人能告诉我为什么我的按钮没有显示吗?

最佳答案

</ script>不是有效的 HTML 标记。将这些更改为 </script> .

关于javascript - 按钮未在 AngularJs 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31621036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com