没有在Angular应用程序中定义firebase(在firebase迁移之后)

firebase is not defined in Angular app (after Firebase migration)

本文关键字:firebase 迁移 之后 Angular 应用程序 定义      更新时间:2023-09-26

嗨,我正试图从Firebase上的数据库中以角度检索信息。但是,我收到一个错误'firebase is not defined'

var config = {
    databaseURL: 'https://console.firebase.google.com/project/face-find-31e52/database/data/',
};
    firebase.initializeApp(config);                           
    firebase.database().ref    
    ('/project/app-name/database/data').once('value').then(function(snapshot) {                                        
          $scope.data = snapshot.val();
    });

*注意,我现在的url中没有用于身份验证的用户id,因为我正在测试应用程序(一次解决一个问题,对吗?)

在链接我的app.js 之前,我在html中包含了firebase库

 <script src="https://www.gstatic.com/firebasejs/3.0.0/firebase.js"></script>

我还记得把这个包括在我的角度:

angular.module('starter', ['ionic', 'ngCordova','firebase'])
.controller("ExampleController", function ($scope, $cordovaCamera,$cordovaToast,$firebaseObject) {

是的,我正在构建一个离子应用程序,但我不认为这对firebase有任何干扰。有人知道我为什么无法检索数据吗?非常感谢帮助。谢谢

Angularfire 1.3(截至撰写本文时的当前版本)不支持新的Firebase SDK。查看AngularFire 2.0版本的拉取请求。它应该在NPM中,并且很快:)