1

AngularFireFirebaseとAngularJSの間のインターフェイスライブラリ)を使用しています。AngularFireを使用してFirebase JSメソッドを呼び出す方法

javascriptメソッドsendEmailVerification()を角度コードで呼びたいと思います。私は、次のコードを実装するとき、私はエラーを得る:$scope.authObj.sendEmailVerification is not a function.おそらく私はAngularJS(AngularFire)でjavascriptメソッドを使用しようとしているためです。

AngularFireを使用してJavascriptメソッドを使用する方法はありますか?

$scope.signUp = function() { 

    $scope.authObj.$createUserWithEmailAndPassword($scope.email, $scope.password) 
    .then(function(firebaseUser) { 

     $scope.sendVerifyEmail(); 

    }).catch(function(error) { 
     console.error("Error: ", error); 
    }); 
} 

$scope.sendVerifyEmail = function(){ 
    $scope.authObj.sendEmailVerification(); 
} 

答えて

2

私はちょうど私が必要Firebase方法でapp.controller外のJavaScript関数を記述および角度方法内側app.controllerすなわち内部からそれを呼び出すことができることを考え出しました。以下は

は、上記のJS関数は、角度の関数以下から呼び出され

// The below JS function written outside app.controller 
function sendVerifyEmail(firebaseUser){ 
    firebaseUser.sendEmailVerification(); 
} 

私の更新されたコードである

$scope.signUp = function() { 

    $scope.authObj.$createUserWithEmailAndPassword($scope.email, $scope.password) 
    .then(function(firebaseUser) { 

     sendVerifyEmail(firebaseUser); 

    }).catch(function(error) { 
     console.error("Error: ", error); 
    }); 
} 
関連する問題