0
我正在嘗試與Firebase一起設置AngularJS Ionic應用程序。
我遵循所有可用的指南,但仍然未定義Firebase對象。
這是我的index.html:(身體內部)AngularFire - Firebase對象undefined
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/ionic/release/js/ionic.js"></script>
<script src="bower_components/ionic/release/js/ionic-angular.js"></script>
<script src="bower_components/ngCordova/dist/ng-cordova.js"></script>
<script src="bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js"></script>
<script src="bower_components/angular-translate/angular-translate.js"></script>
<script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script src="bower_components/localforage/dist/localforage.js"></script>
<script src="bower_components/ionic-platform-web-client/dist/ionic.io.bundle.min.js"></script>
<script src="bower_components/firebase/firebase.js"></script>
<script src="bower_components/angularfire/dist/angularfire.min.js"></script>
<!-- endbower -->
<script>
firebase.initializeApp({
apiKey: "...",
authDomain: "....firebaseapp.com",
databaseURL: "....firebaseio.com",
storageBucket: "....appspot.com"
});
</script>
<!-- endbuild -->
,這是我app.js:
'use strict';
angular.module('...', ['main', 'firebase'])
.constant('FBURL', 'https://....firebaseio.com')
.factory('Auth', function ($firebaseAuth, FBURL) {
var ref = new Firebase(FBURL);
return $firebaseAuth(ref);
});
服務 - $ firebaseAuth,加載成功,但行新火力地堡拋出Firebase未定義的異常。
謝謝!
您正在使用什麼版本的火力地堡的? –
Firebase - 3.2.0 AngularFire - 2.0.1 –
我剛剛遇到了這個問題,一個星期前,我不知道我遇到了這個問題,但我的工作時,我用var ref = firebase.database() .REF();注意「firebase」的外殼。然後我將ref傳遞給$ firebaseArray函數。至於$ firebaseAuth(),我只需要引用它並調用相應的認證功能。 –