0
Facebook、Twitter、Google &電子メールでログインできるように自分のアプリケーションをセットアップしました。しかし、私はそれが戻って、以下のエラーメッセージをもたらすように働くことができない後者の1つ。私app.jsでAngularとFirebaseで電子メールログインを修正するにはどうしたらいいですか?
angular.js:13550 TypeError: Cannot read property 'email' of undefined
at Scope.$scope.loginEmail (main.js:34)
at fn (eval at <anonymous> (angular.js:14432), <anonymous>:4:221)
at expensiveCheckFn (angular.js:15485)
at callback (angular.js:25018)
at Scope.$eval (angular.js:17229)
at Scope.$apply (angular.js:17329)
at HTMLButtonElement.<anonymous> (angular.js:25023)
at HTMLButtonElement.jQuery.event.dispatch (jquery.js:4737)
at HTMLButtonElement.elemData.handle (jquery.js:4549)
あなたは
theBigWeddingBook.factory('Auth', function ($firebaseAuth) {
var ref = new Firebase("https://the-big-wedding-book.firebaseio.com/");
return $firebaseAuth(ref);
});
を見ることができます。そして、私のmain.jsに私はすべてのログインを制御AuthCtrlをクリートしているように私はAUTHという名前の工場を作成しました。もう一度これを見ることができます。
heBigWeddingBook.controller('AuthCtrl', function($scope, Auth){
Auth.$onAuth(function(authData) {
$scope.authData = authData;
console.log(authData);
})
$scope.loginFacebook = function() {
Auth.$authWithOAuthPopup("facebook").catch(function(error){
console.error(error);
})
}
$scope.loginTwitter = function() {
Auth.$authWithOAuthPopup("twitter").catch(function(error){
console.error(error);
})
}
$scope.loginGoogle = function() {
Auth.$authWithOAuthPopup("google").catch(function(error){
console.error(error);
})
}
$scope.loginEmail = function() {
Auth.$authWithPassword({
email: $scope.user.email,
password: $scope.user.password
}).catch(function(error){
console.error(error);
})
}
$scope.logout = function() {
Auth.$unauth();
}
});
私は何が間違っているのか分かりません。 Firebaseで設定した電子メールとパスワードでログインしようとしています。誰かが私を正しい方向に向けるかもしれませんか?
ありがとうございました
はfirebaseに関連していないため、$ scope.userは未定義です。したがって、$ scope.userからの電子メールの読み取りは例外をスローします。 –
どうすれば$ scope.userをユーザのメールとして定義するのですか? –
あなたは '$ scope.user = {};'のようなことをすることができますが、あなたのビューを再確認する必要があります。あなたのフォームに ''あなたのコントローラコードを見てください –