firebase执行方法两次
我已经建立了一个firebase简单登录,它在我的angular项目中工作。然而,出于soem的原因,当我调用包含login和createUser方法的函数时,它们会被调用两次 控制器设置如下:firebase执行方法两次,firebase,Firebase,我已经建立了一个firebase简单登录,它在我的angular项目中工作。然而,出于soem的原因,当我调用包含login和createUser方法的函数时,它们会被调用两次 控制器设置如下: angular.module('webApp') .controller('AccountCtrl', function($scope, $window, $timeout) { var ref = new Firebase('https://sizzling-fire-4246
angular.module('webApp')
.controller('AccountCtrl', function($scope, $window, $timeout) {
var ref = new Firebase('https://sizzling-fire-4246.firebaseio.com/');
这两种方法都直接从他们网站上的firebase示例放在我的函数中
当我按register时,它将创建用户并对其进行身份验证,然后它将再次运行并告诉我电子邮件已被接收
我已经检查过是否有超时,但这种情况仍然存在
$scope.login = function(){
$scope.loginErrors = [];
$scope.loginSuccess = '';
var user = $scope.loginUser;
if(user.email === ''){
$scope.loginErrors.push('Please enter your email');
}
else if(user.password === ''){
$scope.loginErrors.push('Please enter your password');
}
else if(user.email === 'Admin'){
$window.location.href = '/#/admin';
} else {
ref.authWithPassword({
email : user.email,
password : user.password
}, function(error, authData) {
if (error) {
switch(error.code) {
case 'INVALID_EMAIL':
$scope.loginShow = true;
$timeout( function(){ $scope.loginMessage = 'Please enter a valid email address'; }, 500);
break;
case 'INVALID_USER':
$scope.loginShow = true;
$timeout( function(){ $scope.loginMessage = 'Please enter a valid user address'; }, 500);
break;
case 'INVALID_PASSWORD':
$scope.loginShow = true;
$timeout( function(){ $scope.loginMessage = 'Please enter the correct password'; }, 500);
break;
default:
console.log('error', error);
}
} else {
console.log('Authenticated successfully with payload:', authData);
$window.location.href = '/#/dashboard';
}
});
}
任何帮助都将不胜感激我在开发时遇到了类似的问题,我有两个浏览器选项卡正在运行“浏览器同步”。关闭一个,问题就消失了。调用了两次什么方法?调用它的代码在哪里?考虑一下,为了帮助调试错误,我们需要有足够的代码来复制它。我们能否将其复制/粘贴到浏览器中并运行它以查看问题?看见