我正在尝试使用AngularFire身份验证将我的用户登录到Facebook。当我单击登录时,我看到错误事件fire - angularFireAuth:error但错误的数组为空。我不知道有什么问题或者如何调试。有任何想法吗?
查看:
<div ng-controller="UsersCtrl">
<div id="loginDiv">
<a href="#" ng-click="logout()">Logout</a>
<span ng-show="user">
{{user.name}}
<a href="#" ng-click="logout()">Logout</a>
</span>
<a href="#" ng-hide="user" ng-click="login()">Login</a>
</div>
</div>
控制器:
myApp.controller('UsersCtrl', ['$scope', 'angularFireAuth',
function UsersCtrl($scope, angularFireAuth) {
var url = 'https://inviter-dev.firebaseio.com';
angularFireAuth.initialize(url, {scope: $scope, name: "user"});
$scope.login = function() {
console.debug("logging in")
angularFireAuth.login("facebook");
};
$scope.logout = function() {
angularFireAuth.logout();
};
$scope.$on("angularFireAuth:login", function(evt, user) {
console.debug("login event", user)
});
$scope.$on("angularFireAuth:logout", function(evt) {
console.debug("logout event", user)
});
$scope.$on("angularFireAuth:error", function(evt, err) {
console.debug("auth error", err)
// There was an error during authentication.
});
}
]);
答案 0 :(得分:0)
此问题似乎与js依赖项的放置和排序问题有关。我将这些依赖项移到了HTML Head中,它可以运行:
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase-auth-client.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"> </script>
<script type="text/javascript" src="js/vendor/angular/angularFire.js"></script>
<script type="text/javascript"src="https://cdn.firebase.com/v0/firebase-simple-login.js"></script>