Ionic + firebase,错误模块“firebase”不可用

时间:2021-09-24 19:38:24

I'm using the latest ionic and I want to implement a firebase backend for my app. I followed the ionic get started guide, then used bower install to install firebase and angular fire.

我正在使用最新的ionic,我想为我的应用实现一个firebase后端。我遵循ionic get started guide,然后使用bower install安装firebase和角fire。

The error produced is:

产生的错误是:

Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module firebase due to:
Error: [$injector:nomod] Module 'firebase' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

So adding the firebase links to the index.html does not fix this issue at least for me. Using bower to install firebase it should bundle automatically just by passing in 'firebase' into the controller.js, however it produces this error. Any ideas? Thanks in advanced!

因此,向索引添加firebase链接。html至少对我来说不能解决这个问题。使用bower安装firebase时,只需将“firebase”传入控制器就可以自动绑定。但是它会产生这个错误。什么好主意吗?由于先进的!

This is all that I've changed in the app thus far:

这就是到目前为止我在应用程序中所做的所有改变:

Index.html

index . html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
  </head>
  <body ng-app="starter" animation="slide-left-right-ios7">
    <!-- 
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable nav-title-slide-ios7">
      <ion-nav-back-button class="button-icon icon  ion-ios7-arrow-back">
        Back
      </ion-nav-back-button>
    </ion-nav-bar>
    <!-- 
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->
    <ion-nav-view></ion-nav-view>
  </body>
</html>

app.js

app.js

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

controller.js

controller.js

angular.module('starter.controllers', ['firebase'])

.controller('DashCtrl', function ($scope, $firebase) {

  // TV Shows Table
  var moviesRef = new Firebase("https://moviehunt.firebaseio.com/");
  var sync = $firebase(moviesRef);
  $scope.movies = sync.$asArray();

})

1 个解决方案

#1


2  

Okay, here was my solution, I started from scratch completely, instead created the ionic app with a side menu:

好的,这是我的解决方案,我从头开始,用一个边菜单创建了ionic应用程序:

ionic start myApp sidemenu

离子开始myApp sidemenu

then used bower and bower install firebase install angularfire

然后用凉亭和凉亭安装火座

and then added the following html links to the index.html:

然后在index.html中添加以下html链接:

<script src="lib/firebase/firebase.js"></script>
<script src="lib/firebase-simple-login/firebase-simple-login.js"></script>
<script src="lib/angularfire/dist/angularfire.js"></script>

#1


2  

Okay, here was my solution, I started from scratch completely, instead created the ionic app with a side menu:

好的,这是我的解决方案,我从头开始,用一个边菜单创建了ionic应用程序:

ionic start myApp sidemenu

离子开始myApp sidemenu

then used bower and bower install firebase install angularfire

然后用凉亭和凉亭安装火座

and then added the following html links to the index.html:

然后在index.html中添加以下html链接:

<script src="lib/firebase/firebase.js"></script>
<script src="lib/firebase-simple-login/firebase-simple-login.js"></script>
<script src="lib/angularfire/dist/angularfire.js"></script>