Encountered an error when creating my own AngularJS module: Unable to instantiate

Attempting to dive into TypeScript and AngularJS, I encountered a perplexing error after following a tutorial for just a few lines.

It appears that there may be an issue with my mydModule?

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module mydModule due to:
Error: [$injector:nomod] Module 'mydModule' 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.

index.html

<html ng-app="mydModule">
<body>    
    <script src="Scripts/angular.js"></script>
    <script src="App_Scripts/start.js"></script>
    <script src="App_Scripts/startController.js"></script>
    <div class="wrapper container">
        <div class="row"  ng-controller="startController as vm">    
                <div id="content">
                    Tst:
                    <ul>
                        <li ng-repeat="label in vm.sequence">
                            <span ng-style="{'background-color':label.Color}">{{label.Text}}</span>
                        </li>
                    </ul>
               </div>
       </div>
   </div>
</body>
</html>

start.ts

/// <reference path="../scripts/typings/angularjs/angular.d.ts" />
module DosierradApplication {
    export class StartPage {
        static mydModule = angular.module('startPage', ['ngResource']);
    }
}

startController.ts

/// <reference path="../scripts/typings/angularjs/angular.d.ts" />
/// <reference path="start.ts" />
module DosierradApplication {
    export class startController {
        constructor(private $scope: ng.IScope) {

        }

        sequence = [
            {
                "Id": 0,
                "Text": "all good",
                "Color": "#0f0"
            },
            {
                "Id": 1,
                "Text": "not good",
                "Color": "#ff0"
            }
        ];
    }

    StartPage.mydModule.controller('startController', ["$scope", startController]);
}

Answer №1

In this scenario, you have named your module as 'startPage' but are attempting to access it using the name 'mydModule'. The correct way to reference it would be

<html ng-app="startPage">

The term mydModule represents a variable name and not the actual module name in the given example.

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

Is it unorthodox to utilize constructor instances as prototypes in "WebGL - Up and Running"?

In the book "WebGL - Up and Running," a unique custom geometry is created in a rather straightforward manner. However, what caught my attention was the penultimate line of code. Here's how it looked: Saturn.Rings = function ( innerRadius, outerRadius ...

Verify if a certain value exists in an array while using ng-if inside ng-repeat

Currently, I have a loop using ng-repeat that goes through a list of wines obtained from an API. Alongside this, there is an array variable containing all the IDs of wines that have been marked as favorites and retrieved from the database. My goal is to sh ...

Is there a way to deactivate keyboard input on an HTML number input field? How about in a React or Material-UI environment?

I am working with an <input> tag that has the attribute type="number", and I want to disable keyboard input so that users are required to adjust the value using the spinner (up and down arrows). This will allow me to consume the input value on each c ...

Issue with form validation in Bootstrap 5.2 JavaScript implementation

I'm having trouble with my client-side form validation not working properly before the server-side validation kicks in. I've implemented Bootstrap 5.2 and followed the documentation by adding needs-validation and novalidate to the form. Scenario ...

Display multiple items from a JSON object in Django on the following page

I need to implement a feature that allows users to select multiple entries from a JSON object displayed in an HTML table. After selecting their entries and submitting, they should be redirected to a new page where only their chosen items are shown for conf ...

Executing Javascript code that has been retrieved using the XMLHttpRequest method in a

Would it be feasible to modify this code to function recursively if the redirects to the js file that needs to be executed? function loadScript(scriptUrl) { var xhr = new XMLHttpRequest(); xhr.open("GET", scriptUrl); xhr.onready ...

The calculator is experiencing issues with JavaScript functionality

Having some trouble developing a calculator using HTML5, CSS, and JavaScript. After passing my HTML and CSS through validators successfully, I encountered issues when adding JavaScript functions to enable the functionality of the buttons on the calculator. ...

Guide on populating a Vue.js input field with a value retrieved from a JSON object

Could someone please assist me with a problem I am encountering? I need to extract and display the values from an input form for "name" and "position", but the data is in JSON format. {"id":5,"name":"the name","pos":"the position"} This code snippet repr ...

What is the most effective way to load data prior to the controller being loaded

Is there a way to fetch data from a service before the view and controller are loaded? I need assistance with this. resolve: { getAlbum: function(albumService){ return albumService.getAlbums(); },getAtum: function(albu ...

Is there a way to detect duplicate usernames in a form without actually submitting the form, and then automatically focus on the username field if a duplicate is

I need help with a user registration form that I am creating. I want the form to automatically search for an existing username as soon as the user starts typing in the username field. If the username already exists, I want the field to receive focus. In my ...

Handling dynamic routes with React Router 4 and the 404 path

I have been working with the latest version of React Router (4) and have implemented a dynamic route configuration as described in the tutorial. The routes are functioning correctly, except for when I tried to add a 404 path following the tutorial's i ...

The altered variable refuses to show up

Currently, I am working on a project to create a Skate Dice program that will select random numbers and display the results simultaneously. Unfortunately, I have encountered an issue where the randomly generated number is not being shown; instead, it dis ...

Enhance Functionality Using SetInterval / SetTimeout

I'm venturing into creating a "Clock" directive to enhance my knowledge of Angular. How can I ensure that it continues to "tick?" Take a look at my attempt here on this fiddle Link: angular.module('app') .directive('clock' , func ...

Unlocking Node.js packages within React JS is a seamless process

Currently, I am developing a React Serverless App with AWS. I am looking for ways to incorporate a Node JS specific package into the React JS code without requiring Node JS on the backend. One package that I need access to is font-list, which enables list ...

Having trouble with expressJs router.post() not functioning properly with multiple middleware, resulting in an [object Undefined] error

I have been working on developing a REST API for my users, utilizing express-validator for validation before adding the user to the database. However, I encountered an issue while chaining my middleware in the router.py file which resulted in the error Err ...

navigate to a different section on the page with a series of visuals preceding it

When I try to navigate to a specific dom element on another page, the page initially works fine but then jumps to somewhere before that element. I believe this issue occurs because the page calculates the position before images load, and once the images ar ...

When attempting to insert a date into a MySQL database using React.js, I encountered an issue with the date format

Hey everyone, I have set the input date to dd/mm/yyyy format using moment(donors.donateDate).format('DD-MM-YYYY'). However, when I click the submit button, an error is displayed in the console stating: The specified value "23-03-2022" ...

The JavaScript code is not running as expected!

i have this index.html file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" ...

The result of Coordinates.speed is consistently null

I'm working on a project that involves changing the speed of background particles based on the user's device speed (like when they are in a car or bus). I thought the Geolocation API would be a perfect fit, specifically the Coordinates.speed prop ...

leveraging the phonegap plugin with AngularJS application

Currently, I am integrating AngularJS with a custom Cordova plugin that exports an object called deviceAttributes containing various methods. Do I need to make any adjustments in my JavaScript code to access the methods of this object? The console output s ...