2016-09-11 5 views
0

방금 ​​AngularFire에 샷을주었습니다. 오류가 발생했습니다. 여기

내가 내 index.html을에있는 것입니다 : 여기

<!-- Angular --> 
    <script src="bower_components/angular/angular.min.js"></script> 

    f<!-- Firebase --> 
    <script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script> 

    <!-- AngularFire --> 
    <script src="https://cdn.firebase.com/libs/angularfire/2.0.2/angularfire.min.js"></script> 

    <script> 
    // Initialize 
    var config = { 
     apiKey: "mykey", 
     authDomain: "mydomain", 
     databaseURL: "myurl", 
     storageBucket: "mybucket", 
    }; 
    firebase.initializeApp(config); 
    </script> 

내 주요 응용 프로그램 모듈 : 여기

angular.module('myApp', [ 
    'firebase', 
    'home', 
    'login_modal', 
    'navbar', 
    'ngAnimate', 
    'ui.bootstrap', 
    'ui.router' 
]); 

내가 함께 AngularFire를 사용하려고 시도하는거야 모듈입니다 :

angular.module('login_modal', [ 
    'firebase' 
]) 

다음은 Angular UI Bootstrap 모달을 사용하는 컨트롤러입니다 (AngularFire 코드는 중간 정도입니다).

// This just creates the modal instance 
angular.module('login_modal').controller('login_modal_controller', function ($rootScope, $uibModal, $log) { 
    var $ctrl = this; 

    $ctrl.animationsEnabled = true; 

    $rootScope.open_login_modal = function (size) { 
    var modalInstance = $uibModal.open({ 
     animation: $ctrl.animationsEnabled, 
     ariaLabelledBy: 'modal-title', 
     ariaDescribedBy: 'modal-body', 
     templateUrl: 'myModalContent.html', 
     controller: 'ModalInstanceCtrl', 
     controllerAs: '$ctrl', 
     size: size, 
     resolve: { 
     sign_up: function() { 
      return $ctrl.sign_up; 
     } 
     } 
    }); 
    }; 
}); 


angular.module('login_modal').controller('ModalInstanceCtrl', ['$scope', '$firebaseAuth', function($uibModalInstance, $scope, $firebaseAuth) { 
    var $ctrl = this; 

    $ctrl.sign_up = true; 
    $ctrl.email = ''; 
    $ctrl.password = ''; 
    $ctrl.school = ''; 

    // *** error is here: error at $ctrl.auth (login_modal.controller.js:41) 
    $ctrl.auth = function(){ 
    var auth = $firebaseAuth(); 

    $ctrl.firebaseUser = null; 
    $ctrl.error = null; 

    if($ctrl.sign_up){ 
      auth.$createUserWithEmailAndPassword($ctrl.email, $ctrl.password) 
      .then(function(firebaseUser){ 
      alert("User " + firebaseUser.uid + " created successfully!"); 
     }) 
     .catch(function(error) { 
      alert("Error: ", error); 
     }); 
    } 

    else { 
     auth.$signInWithEmailAndPassword($ctrl.email, $ctrl.password) 
     .then(function(firebaseUser){ 
     alert("Signed in as:", firebaseUser.uid); 
     }) 
     .catch(function(error) { 
     alert("Authentication failed:", error); 
     }); 
    }  
    }; 

    $ctrl.cancel = function(){ 
    $uibModalInstance.dismiss('cancel'); 
    }; 
}]); 

바닐라 파이어베이스와 관련하여이 작업이 진행 중입니다.

+0

당신은'$ firebaseAuth'를 호출하지 않습니다; 'auth' 속성에 할당하는 것뿐입니다. [전화] (https://github.com/firebase/angularfire/blob/master/docs/migration/1XX-to-2XX.md#firebaseauth-method-renames--signature-changes)가 필요합니다. – cartant

+0

@cartant 맞아, 미안해, 그걸 버리고 내 게시물을 업데이트 했어. 그것은 여전히 ​​나에게 오류를 준다. 명확히하기 위해, 그것은'var auth = $ firebaseAuth()'이어야 함을 의미합니다, 맞습니까? – skwny

+1

그리고 컨트롤러 함수에 대한 리터럴 배열이 매개 변수와 일치하지 않습니다. 하나의 추가 매개 변수가 있으므로'$ scope'도'$ firebaseAuth'도 여러분이 생각하는 것입니다. – cartant

답변

0

@cartant의 의견을 참조하십시오. 내 인라인 생성자 함수의 매개 변수가 잘못되었습니다.

관련 문제