CreateUser function not working in AngularFire - Firebase Simple Login?

I have the following controller that uses AngularFire

app.controller("authController", function($scope, $firebaseSimpleLogin){

var ref = new Firebase("https://myapp.firebaseIO.com/");
$scope.auth = $firebaseSimpleLogin(ref, function(error, user){
    if(error){
        console.log(error);
    }
    else if(user){
        console.log(user);
    }
    else{
        console.log("user logged out");
    }
});

// This shows a valid object
console.log($scope.auth);

$scope.createAccount = function(){
    console.log("found me");
    $scope.auth.$createUser($scope.email, $scope.password, function(error, user){
        console.log("something");
        console.log(user);
        if(!error){
            console.log(user);
        }
        else{
            console.log(error);
        }
    });
};

});

When I tie the function $scope.createAccountto the event ng-clickand click the bind button, the browser works console.log("found me"), but none of the other teams console.login the $scope.createAccountnot displayed.

The command console.log($scope.auth)that I set before the function $scope.createAccountshows a valid object with a specific function $createUser.

I do not get any console errors at startup $scope.createAccount, so I assume the call was successful.

Why can I see the auth object, but don't get the callback after the call $createUser?

+4
1

, JavaScript Angular. AngularFire ( , JavaScript SDK-, $ ), Angular $promise.

$scope.auth.$createUser($scope.email, $scope.password, function(error, user){
    // do things;
});

$scope.auth.$createUser($scope.email, $scope.password)
    .then(function(user){
        // do things if success
    }, function(error){
        // do things if failure
    }); 

.

vanilla JS firebaseSimpleLogin vs Angular $firebaseSimpleLogin. JSP- -, , script, / . :

var auth = new firebaseSimpleLogin(ref, function(error, user){
    if(error){
        // do things if login failure
    }
    else if(user){
        // do things when login succeeds 
    }
    else{
        // do things when user logs out
    }
});

Angular :

$scope.auth = $firebaseSimpleLogin(ref)
    .then(function(user){
        // do things when login succeeds 
    }, function(error){
        // do things when login fails     
    });

. Angular. , , Angular , $watch $scope.auth.user . $scope.auth.user null, . - , null, .

+12

Source: https://habr.com/ru/post/1546885/


All Articles