1

AngularFire (Firebase과 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

I는 I 필요한 중포 기지의 방법으로 app.controller 외부 스크립트 함수 작성 방법 앵귤러 내부 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); 
    }); 
} 
관련 문제