The Firebase Authentication module encountered an uncaught error: [$injector:modulerr]

I encountered a challenge while developing a small task for Gmail user login and logout using Firebase authentication. The issue in my code is

Uncaught Error: [$injector:modulerr]

The libraries I included are:

<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script src="https://apis.google.com/js/platform.js" async defer></script>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>

<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>

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

Also, I configured the firebase settings.

index.html

<html ng-app="appName">  
<body ng-controller="loginCtrl">
    <div id="message">
        <button ng-click="googleSignin()">SignIn into App</button>
    </div>
    <p id="load">Firebase SDK Loading&hellip;</p>
</body>

https://i.sstatic.net/UlR9C.png

On clicking the sign-in button, a Gmail authentication popup appears. After successful authentication, it redirects to the page htmlnew.html

app.js

var app = angular.module("appName", ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
        .when("/", {
            templateUrl: 'assests/index.html',
            controller: 'loginCtrl'
        })
});
 app.controller('loginCtrl', function ($scope) {
 var provider = new firebase.auth.GoogleAuthProvider();
 $scope.googleSignin = function () {
    firebase.auth()

            .signInWithPopup(provider).then(function (result) {
        var token = result.credential.accessToken;
        var user = result.user;
        console.log(token);
        console.log(user);

        firebase.auth().onAuthStateChanged(function user() {
            if (user) {
                window.location = 'htmlnew.html';
            }
        });
    }).catch(function (error) {
        var errorCode = error.code;
        var errorMessage = error.message;
        console.log(errorCode);
        console.log(errorMessage);
    });
  }
});

 app.controller('SecondController', [function ($scope) {
    $scope.googleSignout = function () {
        firebase.auth().signOut()
                .then(function () {
                    console.log('Signout Succesfull');
                }, function (error) {
                    console.log('Signout Failed');
                });
     }
 }]);

htmlnew.html

<html data-ng-app="appName">
<body ng-controller="SecondController">
    <div id="message">
        <h1>Welcome</h1>
        <button ng-click="googleSignout()">Google Signout</button>
    </div>

</body>

https://i.sstatic.net/zkmtw.png

The issues faced are:

1.) Upon entering the htmlnew.html page, an Uncaught Error: [$injector:modulerr] error is thrown.

https://i.sstatic.net/B9YsV.png

2.) The Signout functionality is not working properly

Answer №1

Don't forget to add the fireBase module name in your app declaration.

angular.module('appName', ['ngRoute','firebase'])

For more information, check out this tutorial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to retrieve specific JSON data from an array in JavaScript using jQuery, especially when the property is

Forgive me if this question seems basic, I am new to learning javascript. I am currently working on a school project that involves using the holiday API. When querying with just the country and year, the JSON data I receive looks like the example below. ...

Instructions for removing a class using the onclick event in JavaScript

Is there a way to make it so that pressing a button will display a specific class, and if another button is pressed, the previous class is removed and a new one is shown? Thank you for your assistance. function myFunction() { document.getElementById ...

When attempting to utilize nsIPrefBranch in a Firefox extension to save data, an unexpected error of NS_ERROR_UNEXPECTED occurs

I am facing a challenge with saving persistent data in a Firefox extension. Currently, I am attempting to utilize nsIPrefBranch in the following manner: var db = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.ns ...

Issue encountered while initializing session_start() in PHP REACTJS AXIOS

https://i.sstatic.net/bSelX.pngWhen attempting to log in to my web application, I encountered an issue where the session is not opening after entering the correct email and password. Strangely, there is no PHPSESSID present in the console > application. ...

Master the art of using useMutation from react-query: Learn how to handle error messages and success notifications effectively!

Currently in my Next.js project, I have integrated react-query to retrieve data from MongoDB. Within my form, a POST request is sent using the useMutation hook: /*** components ***/ import {Button, InputGroup} from "../index"; import {useMutatio ...

Does Next js Backend support multithreading as a default feature?

As I begin my project, I am utilizing the built-in Node js server within Next js by running the next start command. However, I am uncertain as to whether it has multithreading capabilities. My inquiry is this: Would you suggest sticking with the built-in ...

Guide on downloading a PDF file with NodeJS and then transmitting it to the client

My goal is to download a PDF file using NodeJS and then send its data to the client to be embedded in the page. Below is the code snippet I am using to download the PDF file: exports.sendPdf = function(req, responce) { var donneRecu = req.body; va ...

Guide on incorporating a promise call within a forEach loop

angular.forEach(data.rows, function(value, key){ var cell = []; subId = 0; angular.forEach(vm.tableJson, function(value1, key1){ if(value1.Type != 'table'){ if(key == 0){ vm.columns.push(valu ...

What is the best way to combine API calls using rxJs subscribe and map in Angular?

Currently, I am executing multiple API requests. The first one is responsible for creating a User, while the second handles Team creation. Upon creating a User, an essential piece of information called UserId is returned, which is crucial for the Team cre ...

Implementing mouse event listeners on dynamically created elements in Vue.js

I've been curious if anyone has attempted something similar to the following code snippet (created within a Vue.js method): for (let i = 0; i < this.items.length; i++) { let bar = document.createElement('div'); bar.className = this ...

Implementing a one-time watcher with user input in Vue.js

I am facing an issue with using the input tag in a Vue template. I need to change the type from 'password' to 'text'. <input type="text" v-model="form.password" /> To achieve this, I have created a watch code to convert text s ...

Enhance the size of dynamically generated svg elements by scrolling the mouse wheel in and out

In my ASP.NET application, I have a view page where SVG elements are dynamically generated. Now, I want to implement zoom functionality for all the created SVG elements. Zooming in should occur when scrolling up and zooming out when scrolling down. <sv ...

Where to begin with Angular materials?

Here is a snippet of my Angular materials test code: <div class="radioButtondemoBasicUsage" ng-app="MyApp"> <form ng-submit="submit()" ng-controller="AppCtrl"> <p>Selected Value: <span class="radioValue">{{ data.group1 }}< ...

Setting the selected option of a select form element dynamically in Vue 3

Is there a way to dynamically set the selected option in Vue 3 when the data value doesn't match any available option value? Situation: If Florida (FL) is the stored state value and the country changes from United States (US) to Canada (CA), the Sta ...

The occurrence of events for a basic model in Backbone is inexplicably non

I attempted to save some model data on localStorage (and even tried to catch this event and log some text to the console), but it didn't work - no errors and no events either. Here is my JavaScript code: var app = { debug: true, log: func ...

What is the best way to enable and disable the edit-in-place feature using jQuery?

Recently, I decided to experiment with the jQuery In Place Editor but I've come across an issue I can't seem to solve. Below is the code snippet that I have been working on. In my implementation, I am utilizing the jQuery toggle method to enable ...

Challenges with Page Loading in Selenium

Inquiry: When a URL is accessed in a web browser, the page begins to load. A loading symbol appears at the top, and once it stops, our selenium script continues with the next steps. However, there are instances where the page takes longer to load all its ...

Using OPTIONS instead of GET for fetching Backbone JS model data

Currently, I am attempting to retrieve data from a REST endpoint with the help of a model. Below is the code snippet that I am using: professors: function(id) { professor = new ProfessorModel({ id: id }); professor.fetch({ headers: { ...

Cancelling an ongoing AWS S3 upload with Angular 2/Javascript on button click

I'm currently working with Angular 2 and I have successfully implemented an S3 upload feature using the AWS S3 SDK in JavaScript. However, I am now facing a challenge: how can I cancel the upload if a user clicks on a button? I've attempted the ...

Switch between Coordinated Universal Time and a designated time zone using the New Internationalization API

I am experimenting with the new Internationalization API using Chrome Version 31.0.1623.0 canary. My goal is to: Convert Date Time between UTC and a specific time zone (America/New_York as an example). Determine if the conversion takes into account Dayl ...