Error: Unable to find module 'app' in the injector. This issue is specific to Firefox browser

I've hit a roadblock with this issue. Despite reading extensively about it, I can't seem to solve it. The problem arises when I declare my <script> app.js before utilizing ng-app, leading to the following error:

Failed to instantiate module app due to:

[$injector:nomod] Module 'app' 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.

This particular error only surfaces on Firefox.

Html :

<html lang="en-US">
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <link rel="stylesheet" type ="text/css" href="css\bootstrap.min.css"/>
    <link rel="stylesheet" type ="text/css" href="css\component.css"/>
    <link rel="stylesheet" type ="text/css" href="css\app.css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
    <script type="text/javascript" src="js\modernizr.custom.js"></script>
    <script type="text/javascript" src="js\ui-bootstrap-tpls-1.2.4.min.js"></script>
    <script src="js\app.js"></script>

</head>

<body ng-app="app">>

    <div class="top row">

        <top-header></top-header>

        <home-carousel></home-carousel>

    </div>

 </body>
 </html>

js :

app.directive('topHeader', function() {
  return {
    restrict: 'E',
    templateUrl: 'topHeader.html',
    controller: function ($scope, $window) {

    name = $window.location.pathname;
    n = name.lastIndexOf("/");
    name = name.substring(n + 1);
    if (name === "index.html" || name === "")
        $scope.current = '1';
    else if (name === "resume.html")
        $scope.current = '2';
    else if (name === "projects.html")
        $scope.current = '3';

    }
 };
});

app.directive('homeCarousel', function() {
return {
    restrict: 'E',
    templateUrl: 'homeCarousel.html',
    controller: function ($scope)
    {
        $scope.myInterval = 5000;
        $scope.noWrapSlides = false;
        $scope.active = 0;
        var slides = $scope.slides = [];
        var currIndex = 0;

        $scope.addSlide = function()
        {
            slides.push(
            {
                image: "image" + currIndex+ ".jpg",
                id: currIndex++
            });
        };

        for (var i = 0; i < 3; i++)
        {
            $scope.addSlide();
        }
    }
};
});

Answer №1

Consider substituting the backslash with a forward slash in this particular instance

<script src="js\app.js"></script>

to

<script src="js/app.js"></script>

This small modification could be causing issues with your browser's functionality.

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

Managing the invocation of a promise multiple times in AngularJS, and handling some specific exceptions

After previously asking a question on handling promises multiple times in AngularJS (AngularJS handle calling promise multiple times), I am facing a new challenge. This time, I need to retrieve a list of cities, but encounter an exception. Similar to how ...

Proxies: Invoking static methods from the parent of the target object through a proxy

Here's an intriguing challenge for JavaScript enthusiasts Can you intercept property access in JavaScript using proxies? By applying a clever hack like the one demonstrated below, it's possible to intercept static property access within a class ...

Using a combination of nested fetch() and array.map() does not allow for the return

My previous coding experience didn't present any issues with rendering HTML. Typically, I only needed to use one fetch() function. However, in this particular scenario, it appears that I require two fetch calls. The first fetch retrieves a product ID ...

How can I click on an element using either the href or span substring in Protractor?

Here are the details of the element I am trying to interact with using Protractor. <hsx-nav-menu-group hsx-html-element> == $0 <hsx-nav-menu-info> <i hsx-html-element hsx-icon> <svg> <use ...

Leveraging Javascript within MVC3, either on a master page or child page

I'm currently developing a web application utilizing MVC3 and I am curious about the best practices for incorporating JavaScript. Specifically, I am uncertain about whether to include JavaScript in the master page as well as in individual child pages. ...

Populating an array with JSON data using an AngularJS service

I am working on an angularjs service where I need to populate an array using data from an API. The array should be structured like this: var results = [ {id: 1, name: 'John'}, {id: 2, name: 'Jane} ] Currently, my function for fetching ...

Problem with YouTube iFrame API in IE when using JavaScript

Apologies for the unclear heading, but I'm facing a peculiar issue. The YouTube iFrame API works perfectly on all browsers except Internet Explorer. In IE, none of the JavaScript code runs initially. However, when I open DevTools and refresh the page, ...

Adding default Google fonts to text elements in a D3.js SVG

Can anyone guide me on how to integrate Google fonts into a d3 text element? For example: g.append('text') .attr('x', width / 2) .attr('y', height / 3) .text('roboto') .style("font-family" ...

Establishing the types of object properties prior to performing a destructuring assignment

Consider a scenario where a function is utilized to return an object with property types that can be inferred or explicitly provided: const myFn = (arg: number) => { return { a: 1 + arg, b: 'b' + arg, c: (() => { ...

Sharing JSON data between two Backbone views

Could you provide some guidance on how to pass dynamic JSON data from one view to another? In the initial view, I am creating the JSON object using the following syntax: json.push({ first: value, second: value }); ...

What is the process of calculating the difference between two time values in PHP?

I have searched everywhere online and tried multiple methods over the past couple of days, but still can't seem to achieve the desired result. My goal is to subtract two different times, for example 22:00:00 - 00:30:00 = 21:30:00 $hourToEatLastMeal = ...

Shift the content downwards within an 'a' snippet located in the sidebar when it reaches the edge of the right border

I'm having an issue with my style.css file. As a beginner in programming, I am trying to position text next to an image attached in the sidebar. However, the text is overflowing past the border. Here's the HTML code: Please see this first to ide ...

Passing a message from a directive in AngularJS using event broadcasting

Many developers are incorporating the following code snippet into their projects: $rootScope.$broadcast('someEvent', someParameter); Later, in a specific controller: $rootScope.$on('someEvent', function(event, e){ /* code implementat ...

Before inserting a string into JSON in PHP, the length of the string should be included

When sending a POST variable containing a JavaScript dictionary to a PHP file via Ajax, the value of this POST variable is being parsed as a PHP dictionary. However, I noticed that the length of each String value is added before the actual string in the PH ...

Attempting to fetch JSON information but encountering an error message stating "not a valid function."

I have been working on developing a programmer job board app and I am currently facing an issue with displaying JSON data on the main page. My goal is to eventually render the data, but for now, I just want to ensure that it appears in JSON format so that ...

Formulate a multi-line string using a collection in React's JavaScript framework

I'm working on a React function that involves a set and I need to update an HTML element using the data from this set. Below is an example of my code: const updateElement = (mySet) => { document.getElementById('myId').innerHTML = Arra ...

Guide for validating an empty field in AngularJS and creating a custom error message specific to the table row

My table is populated with data from a JSON file, and I am in need of validation for the input fields based on specific rows. The requirement is that users should be able to submit the form only if they fill at least one text box in a particular row. For ...

Converting the keys to lowercase in JSON using Node.js

I am looking to convert the keys in a JSON array from uppercase letters to lowercase keys, as shown below: [ { "_id": "581f2749fb9b6f22308f5063", "WorkshopId": "1", "WorkshopTitle": "workshop1", "WorkshopPrice": "200", ...

What are the best ways to customize exported and slotted components in Svelte?

Is there a similarity between Svelte slots and vanilla-js/dom functionality (I'm having trouble with it). In html/js, I can achieve the following: <style> body {color: red;} /* style exposed part from outside */ my-element::par ...

Closing a Javascript Websocket connection may result in server crash

I encountered an issue while trying to exchange data between my client and server. It seems that every time I closed my client, the server crashed... My server runs on Node.JS using the nodejs-websocket library. After some investigation, I discovered tha ...