Unable to initialize myModule module

An error occurred while trying to instantiate the module 'myModule': [$injector:nomod] Module 'myModule' is not available. Make sure you have spelled the module name correctly and loaded it properly. If you are registering a module, ensure that you specify the dependencies as the second argument.

    <head>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/Script.js"></script>
   </head>

   <body ng-controller="myController">
    <div>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Likes</th>
                    <th>DisLikes</th>
                    <th>Likes/DisLikes</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="technology in technologies">
                    <td>{{ technology.name }}</td>
                    <td>{{ technology.likes }}</td>
                    <td>{{ technology.dislikes }}</td>
                    <td>
                        <input type="button" value="Like" ng-click="incrementLikes(technology)">
                        <input type="button" value="Dislike" ng-click="incrementDislikes(technology)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

   </body>
</html>




 var app = angular.module("myModule", [])



            app.controller("myController", function($scope){
                    var technologies = [{name:"C#", likes:0, dislikes:0},
                    {name:"ASP.NET", likes:0, dislikes:0},
                    {name:"SQL Server", likes:0, dislikes:0},
                    {name:"Angular JS", likes:0, dislikes:0},];

                    $scope.technologies = technologies;

                    $scope.incrementLikes = function(technology){
                        technology.likes++;
                    }

                    $scope.incrementDislikes = function(technology){
                        technology.dislikes++;
                    }


         });

Answer №1

Make sure to include ng-app="myModule" in your HTML template.

If you add it to the html or body tag, it should start functioning properly.

Answer №2

Simply insert ng-app="myModule" into your HTML code,

<body ng-app="myModule" ng-controller="myController">

DEMO

var app = angular.module("myModule", [])
app.controller("myController", function($scope){
 var technologies = [{name:"Python", likes:0, dislikes:0},
                    {name:"Django", likes:0, dislikes:0},
                    {name:"PostgreSQL", likes:0,dislikes:0},
                    {name:"React JS", likes:0, dislikes:0},];
$scope.technologies = technologies;
$scope.incrementLikes = function(technology){
       technology.likes++;
}
 $scope.incrementDislikes = function(technology){
          technology.dislikes++;
 }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
 <body ng-app="myModule" ng-controller="myController">
    <div>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Likes</th>
                    <th>DisLikes</th>
                    <th>Likes/DisLikes</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="technology in technologies">
                    <td>{{ technology.name }}</td>
                    <td>{{ technology.likes }}</td>
                    <td>{{ technology.dislikes }}</td>
                    <td>
                        <input type="button" value="Like" ng-click="incrementLikes(technology)">
                        <input type="button" value="Dislike" ng-click="incrementDislikes(technology)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
   </body>

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

Media queries in CSS appear to be dysfunctional when used on Microsoft Edge

@media (min-width: 992px) and (max-width: 1140px) { .mr-1024-none { margin-right: 0px !important; } .mt-1024 { margin-top: 1rem !important; } .d-1024-none { display: none !important; } } Utilizing the ...

Guide to changing the background color of material ui drawer component using styled-components

Issue with Styling Material Ui Drawer Using Styled Components In my application, I am utilizing a Material ui drawer in conjunction with Styled components. Although I have successfully styled several simple Material ui components using Styled components a ...

Troubles encountered while processing STL file readers

Utilizing STLLoader.js, I am able to render components successfully, however, they all appear with one uniform color which does not resemble real-world components. The image above showcases my implementation in Three.js using STLLoader.js (Binary STL file ...

The server will not accept the 'text/html' content type until it is terminated

I am encountering an issue with serving a simple html page through node. When I specify the content type as text/plain, the plain text of the html file loads correctly. However, when I switch it to "content-type" : "text/html", the browser tab keeps loadi ...

What would be an effective method for sending a multitude of parameters to a controller?

I am currently working on an application that utilizes Java with the Spring framework and Javascript with AngularJs framework. The application features a table displaying a list of objects along with two text fields for filtering these objects. The filteri ...

Examining an Array of Objects Based on Various Attributes

Looking to find a way to check if a similar object already exists in an array of objects. Specifically, I want to know if there is an object with the same make and model properties (Ford Focus): { make: 'Ford', model: 'Focus', co ...

When initiating the Grunt Express Server, it prompts an issue: Error: ENOENT - the file or directory 'static/test.json' cannot be found

I'm currently in the process of updating my app to utilize the Express Node.js library. As part of this update, I have made changes to my Grunt.js tasks to incorporate the grunt-express-server package. However, after running the server successfully, I ...

The "call_crossing_detected" error occurs when attempting to connect a call between two Android devices

My Ionic AngularJS Cordova application is functioning perfectly when receiving calls from the demonstration webpage on Chrome. However, I encounter an issue when trying to initiate a call to the demo site or another device using either the demo API key or ...

Code: Ensuring URL spaces are maintained

In my Angular 4 project, I have a service with a delete API that requires two strings as parameters. Here is an example of how it looks: this.http.delete(this.url + 'api/v1/ReportingService/collectionID/'+ '45902' +'/'+' ...

tips for extracting data from a javascript chart without an internet connection

Recently, I've been exploring a website that contains a fascinating javascript chart displaying a simple time series. When hovering over the data points on the chart, a popup window reveals the exact value of each point. While I am aware of methods t ...

What is the reasoning behind the fact that an Angular form is considered valid when all input fields are left

Why is my form showing up as valid even when all of the input fields are blank, despite having the required keyword in place? <!DOCTYPE html> <html ng-app="myApp"> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com ...

Fill the drop-down menu with the present day's date, month, and year

I'm new to this, so please bear with me. I have some html and jQuery code: $(document).ready(function() { var d = new Date(); var month = d.getMonth() + 1; var year = d.getFullYear(); $("#month").val(month); $("#year").val(year) ...

Managing JSON communications in Scala Play Framework and forwarding them to AngularJS JavaScript

Working on the implementation of a library system using Play Framework and AngularJS. To search for a book in the library, the user enters a keyword value in the input field. This value is received by the controller from a GET request. The task is to searc ...

There is an array present with data filled in, but unfortunately, I am unable to retrieve specific elements

As I work on my WordPress 4.7.2 website, I find myself making an AJAX call. The PHP function handling this call returns an array using wp_json_encode(). When I view the data array in the success callback of the AJAX function, everything looks just as expec ...

Nonspecific _POST parameter error encountered while utilizing XMLHttpRequest()

I am currently experimenting with Ajax to add data into a database using the POST method. However, I am facing an issue where PHP is unable to recognize the post variables being sent. ajax: function createUser() { var _id=document.getElementById('ne ...

Activate all chosen CSS circles

I'm currently working on creating a progress bar using CSS circles. The idea is that when you click on each circle in sequence (1, 2, 3), all three circles and the line connecting them will fill up with red color. If you then go back (3, 2, 1), the co ...

Executing a function within a VueJs 2 component immediately after it has finished loading

How can I retrieve data after a component has finished loading? When I initialize my Vue instance and load the component, the template loads correctly but the functions in the mounted lifecycle hook are not executed, causing the stats object to remain empt ...

Is there a way to upload files in AngularJS without using AJAX or jQuery?

Currently, I am looking to create a gallery that allows for the uploading of multiple images. While I have come across some options that utilize ajax to immediately send the files, I prefer a solution that involves form submission. In addition, I would li ...

Unpredictable Redirection when URL is Clicked using PHP or Javascript

Looking to send users to a random URL from a specific list? For instance: With 3 URLs available - Google.com, Facebook.com, and Yahoo.com <a href="<?php $sites[array_rand($sites)] ?>">Click here</a> Upon clicking the link, users will ...

How can you sift through an array of objects by looking at the elements within another nested array? Are you utilizing Vanilla JS, lodash, or another tool from the

Hey, I'm currently working on a React app where I have a list of projects that are associated with specific technologies. What I want to achieve is allowing the user to select certain technologies using checkboxes and have the project list automatical ...