0

我正在尝试使用 AngularFire 身份验证将我的用户登录到 Facebook。当我单击登录时,我看到错误事件触发 - angularFireAuth:error 但 err 数组为空。我不知道出了什么问题或如何调试。有任何想法吗?

看法:

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


 }
]);
4

1 回答 1

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>
于 2015-12-01T22:46:18.660 回答