0

this 예제에서와 같이 라우터 (ui-router)와 작동하도록 인증하는 기본 Firebase를 얻으려고합니다. 웬일인지 나는 이것을 작동시킬 수 없다. 그것은 모든 주에가는 것을 거부하고 실행 기능에서 오류를 기록하려고 할 때 this 오류로 응답합니다.라우터로 인증하는 Firebase

var app = angular.module('app', ['ui.router']); 

app.run(["$rootScope", "$location", function($rootScope, $location) { 

    $rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) { 
     // We can catch the error thrown when the $requireSignIn promise is rejected 
     // and redirect the user back to the home page 
     if(error === "AUTH_REQUIRED") { 
      $state.go("home"); 
     } 
    }); 
}]); 

app.config(function($stateProvider, $urlRouterProvider, $locationProvider) { 

    $stateProvider 
    .state('home', { 
     url: '/', 
     templateUrl: 'partials/home.html', 
     controller: 'mainController', 
     resolve: { 
      // controller will not be loaded until $waitForSignIn resolves 
      // Auth refers to our $firebaseAuth wrapper in the factory below 
      "currentAuth": ["Auth", function(Auth) { 
       // $waitForSignIn returns a promise so the resolve waits for it to complete 
       return Auth.$waitForSignIn(); 
      }] 
     } 
    }) 
    .state('create', { 
     url: '/create', 
     templateUrl: 'partials/create.html', 
     controller: 'createController', 
     resolve: { 
      // controller will not be loaded until $waitForSignIn resolves 
      // Auth refers to our $firebaseAuth wrapper in the factory below 
      "currentAuth": ["Auth", function(Auth) { 
       // $waitForSignIn returns a promise so the resolve waits for it to complete 
       return Auth.$waitForSignIn(); 
      }] 
     } 
    }) 
    .state('share', { 
     url: '/share', 
     templateUrl: 'partials/share.html', 
     controller: 'shareController', 
     resolve: { 
      // controller will not be loaded until $requireSignIn resolves 
      // Auth refers to our $firebaseAuth wrapper in the factory below 
      "currentAuth": ["Auth", function(Auth) { 
       // $requireSignIn returns a promise so the resolve waits for it to complete 
       // If the promise is rejected, it will throw a $stateChangeError (see above) 
       return Auth.$requireSignIn(); 
      }] 
     } 
    }); 

    $urlRouterProvider.otherwise('/'); 
}); 

app.factory("Auth", ["$firebaseAuth", 
    function($firebaseAuth) { 
     return $firebaseAuth(); 
    } 
]); 

답변

1

당신은 중포 기지 의존성이 누락 :

var app = angular.module('app', ['ui.router', 'firebase']); 
+0

지금 내가이 오류 : 'http://errors.angularjs.org/1.4.4을 여기

내 코드입니다 /$injector/modulerr?p0=app&p1=Error%3A%20....ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.4%2Fangular.min.js%3A20%3A179) 'Firebase JS를 추가했지만 파일 – user3519221

+0

감사합니다. 이것이 올바른 대답이었습니다. AngularFire를 추가하는 것을 잊었습니다. – user3519221

+0

코드 조각을 볼 수 없었습니다. :) 부담없이 받아 들여야합니다. –

관련 문제