2016-06-05 2 views
2

현재 내 앱 프로젝트의 firebase v3에 전달되었지만 인증 시스템이 작동하지 않아 그 이유를 알 수 없습니다.Ionic with Firebase V.3 인증

.controller('loginCtrl', function($scope) { 
     $scope.loginEmail = function(){ 
      firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) { 
       var errorCode = error.code; 
       var errorMessage = error.message; 
      }); 
     }; 
    }) 
    .controller('signinCtrl', function($scope) { 
     $scope.signupEmail = function(){ 
      firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) { 
       var errorCode = error.code; 
       var errorMessage = error.message; 
      }); 
     }; 
    }); 

및 내 양식 :

ReferenceError: email is not defined 

누구든지 나를 도울 수 :

<form> 
     <ion-list> 
      <label class="item item-input"> 
       <span class="input-label">Username</span> 
       <input type="text" placeholder="enter username..." ng-model="data.username"> 
      </label> 
      <label class="item item-input"> 
       <span class="input-label">Email</span> 
       <input type="email" placeholder="[email protected]" ng-model="data.email"> 
      </label> 
      <label class="item item-input"> 
       <span class="input-label">Password</span> 
       <input type="password" placeholder="At least 6 characters" ng-model="data.password"> 
      </label> 
     </ion-list> 
     <button class="button button-stable button-block" ng-click="signupEmail()">Done</button> 
    </form> 

크롬 콘솔은 저에게이 메시지를 반환 여기 내 코드는?

답변

0

firebase 데이터베이스에 전달하기 전에 변수 전자 메일 및 값을 초기화해야한다고 생각합니다. 또한 요소를 선택할 수 있도록 id를 지정하십시오. 암호도 똑같이하십시오.

var email = document.getElementById('email').value; 
 
var password = document.getElementById('password').value;
<form> 
 
     <ion-list> 
 
      <label class="item item-input"> 
 
       <span class="input-label">Username</span> 
 
       <input type="text" placeholder="enter username..." ng-model="data.username"> 
 
      </label> 
 
      <label class="item item-input"> 
 
       <span class="input-label">Email</span> 
 
       <input id="email" type="email" placeholder="[email protected]" ng-model="data.email"> 
 
      </label> 
 
      <label class="item item-input"> 
 
       <span class="input-label">Password</span> 
 
       <input id="password" type="password" placeholder="At least 6 characters" ng-model="data.password"> 
 
      </label> 
 
     </ion-list> 
 
     <button class="button button-stable button-block" ng-click="signupEmail()">Done</button> 
 
    </form>
이제 사용자를 만들 중포 기지를 호출합니다.

firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) { 
 
       var errorCode = error.code; 
 
       var errorMessage = error.message; 
 
      });

+0

그것은 작품입니다! 여전히 오류는 거의 없지만 해결해야합니다! 당신의 도움을 주셔서 대단히 감사합니다 ! –

+0

변수를 초기화하는이 방법은 완전히 잘못되었으므로이 방법을 사용하지 않는 것이 좋습니다. –