我正在尝试与Firebase一起设置一个AngularJS Ionic应用程序。
我遵循了所有可用的指南,但仍然未定义Firebase对象。
这是我的索引.html:(身体内部)
<!-- 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 -->
这是我的应用程序.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 未定义。
谢谢!
'use strict';
angular.module('...', ['main', 'firebase'])
.constant('FBURL', 'https://....firebaseio.com')
.factory('Auth', function ($firebaseAuth) {
var ref = firebase.database().ref();
return $firebaseAuth();
});
https://github.com/firebase/angularfire/blob/master/docs/quickstart.md#7-add-authentication