2016-06-24 2 views
1

firebaseを使用してユーザーを認証しようとしています。 Firebase 2.xxを使用して私のアプリを起動しましたが、Firebase 3.xxにアップグレードした後でも、 というエラーが発生しました。 "onAuthStateChangedは関数ではありません"というエラーです。On Auth Stateが変更されました。AngularFire

これは私のログイン機能が

.controller('HomeCtrl', ['$scope','$location','CommonProp','$firebaseAuth', '$firebaseObject',function($scope,$location,CommonProp,$firebaseAuth,$firebaseObject) { 

    var firebaseObj = $firebaseObject(rootRef); 
    var loginObj = $firebaseAuth(firebaseObj); 

    $scope.SignIn = function($scope, user) { 
    event.preventDefault(); // To prevent form refresh 
    var username = user.email; 
    var password = user.password; 


    loginObj.$signInWithEmailAndPassword({ 
      email: username, 
      password: password 
     }) 
     .then(function(user) { 
      // Success callback 
      console.log('Authentication successful'); 
      $location.path("/welcome"); 
      CommonProp.setUser(user.password.email); 
     }, function(error) { 
      // Failure callback 
      console.log(error); 
     }); 
} 
}]); 

答えて

2

あなたの問題はあなたが$firebaseAuth()$firebaseObjectを渡しているということであるlike-どのように見えるかです。

[$firebaseAuth][1]オブジェクトが次のように初期化されていることを確認してください。コードが正しく動作するはずです。

var loginObj = $firebaseAuth(); 

実証のためにjsFiddleを参照してください。

ここで確認できますAngularFire2

関連する問題