Angularfire和Firebase升级错误:未知提供商:$ firebaseAuthProvider< - $ firebaseAuth

时间:2016-08-31 08:49:38

标签: angularjs firebase angularfire firebase-authentication

我尝试将我的网络应用程序升级到新的firebase 3.3.0(从2.4.0开始),并且还在angularfire上升级到2.0.2(从1.1.3开始)。在更新之前 - 一切正常。

根据本教程进行更新:https://firebase.google.com/support/guides/firebase-web

现在我收到错误:

angular.js:68 Uncaught Error: [$injector:unpr] Unknown provider: $firebaseAuthProvider <- $firebaseAuth <- Auth
http://errors.angularjs.org/1.5.8/$injector/unpr?p0=%24firebaseAuthProvider%20%3C-%20%24firebaseAuth%20%3C-%20Auth(anonymous function) @ angular.js:68(anonymous function) @ angular.js:4511getService @ angular.js:4664(anonymous function) @ angular.js:4516getService @ angular.js:4664injectionArgs @ angular.js:4688invoke @ angular.js:4710enforcedReturnValue @ angular.js:4557invoke @ angular.js:4718(anonymous function) @ angular.js:4517getService @ angular.js:4664injectionArgs @ angular.js:4688invoke @ angular.js:4710(anonymous function) @ angular.js:4526forEach @ angular.js:321createInjector @ angular.js:4526doBootstrap @ angular.js:1758bootstrap @ angular.js:1779angularInit @ angular.js:1664(anonymous function) @ angular.js:31763fire @ jquery.js:3232fireWith @ jquery.js:3362ready @ jquery.js:3582completed @ jquery.js:3617

当然我知道我需要做的所有身份验证方法更改,但应用程序在开始时崩溃。事件无法达到我可以更新我的身份验证方法的程度。有什么问题?试图在chrome dev工具中逐步检查执行情况,看起来它在加载所有依赖项后立即崩溃。

这是我的身份验证模块:

(function() {
  'use strict';
  angular.module('firebase.auth', ['firebase', 'firebase.ref'])

    .factory('Auth', ['$firebaseAuth','Ref', function($firebaseAuth,Ref) {
      return $firebaseAuth(firebase.auth());
    }]);
})();

这是我初始化app firebase连接的参考模块

angular.module('firebase.ref', ['firebase'])
  .factory('Ref', ['$window', 'FBapiKey', 'FBauthDomain', 'FBdatabaseURL', 'FBstorageBucket', function($window, FBapiKey, FBauthDomain, FBdatabaseURL, FBstorageBucket) {
    'use strict';
    // Initialize Firebase
    var config = {
      apiKey: FBapiKey,
      authDomain: FBauthDomain,
      databaseURL: FBdatabaseURL,
      storageBucket: FBstorageBucket,
    };
    firebase.initializeApp(config);

    return firebase.database().ref();
  }]);

试图对这些文件做很多更改 - 仍然是同样的错误 - 所以我认为问题可以在我的项目的不同位置。

1 个答案:

答案 0 :(得分:4)

Managed to resolve it!

As I supposed - problem was different and trivial (despite error message).

Seems that my module name conflicted with one module (with the same name) in angularfire. So only change to do was to change my auth module name (renamed it to firebase.appauth - and now it works! Still some other errors to fix due to upgrade process but app is loading.

(function() {
  'use strict';
  angular.module('firebase.appauth', ['firebase', 'firebase.ref'])

    .factory('Auth', ['$firebaseAuth','Ref', function($firebaseAuth,Ref) {
      return $firebaseAuth();
    }]);
})();