【发布时间】:2015-02-20 12:56:26
【问题描述】:
我是 Angular JS 的新手。我正在尝试使用 Firebase 简单登录将错误从工厂返回给控制器。有人可以帮忙吗???
registrationController.controller('RegistrationController', [ '$scope' ,'$rootScope', '$firebase', '$location' , 'FIREBASE_URL' , 'Authentication',
function($scope , $rootScope , $firebaseSimpleLogin, $location, FIREBASE_URL, Authentication, ) {
$scope.login = function() {
Authentication.login($scope.user);
console.log(error);
$scope.message = error
} //login
}// end of function
]);//RegistrationController
authenticationController.factory('Authentication' , ['$firebase' , '$location' , 'FIREBASE_URL', '$rootScope' , function( $firebaseSimpleLogin , $location, FIREBASE_URL, $rootScope){
var ref = new Firebase(FIREBASE_URL);
var myObject = {
login : function(user){
return ref.authWithPassword({
email : user.email,
password : user.password
}, function(error, authData) {
if (error) {
var error = error
console.log('error');
return error;
} else {
console.log("SUCCESS");
// $rootScope.$evalAsync($location.path('/meetings'));
}
});
}, // login
} // object
return myObject;
}]);
【问题讨论】:
标签: angularjs firebase firebasesimplelogin