Unable to create module instance, despite correct module definition

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../angular/angular-1.6.7/angular.js"/>
    <script src="../angular/angular-1.6.7/angular-route.min.js"/>
    <!--script type="text/javascript" src="../modules/familyTree.js"/>
    <script type="text/javascript" src="../controllers/mainController.js"/ -->
    <script type="text/javascript">
        var test= angular.module("myTest", []);
        test.controller("main", ["$scope",function ($scope) {
            $scope.headline = "Starting Now";
        }]);
    </script>
</head>
<body ng-app="myTest">
<div ng-controller="main">
    <h1>{{headline}}</h1>
    {{1+2}}
</div>
</body>
</html>

Trying to fix this code but can't figure out what's causing the error.

If you have any insights, any help would be greatly appreciated.

Thank you in advance.

angular.js:116 Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' 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.
http://errors.angularjs.org/1.6.7/$injector/nomod?p0=myApp
    at file:///D:/src/main/resources/templates/angular/angular-1.6.7/angular.js:116:12
    at file:///D:/src/main/resources/templates/angular/angular-1.6.7/angular.js:2303:17
    at ensure (file:///D:/src/main/resources/templates/angular/angular-1.6.7/angular.js:2224:38)

Answer №1

Make sure to properly close the script tags for all the references.

Update

From

 <script src="../angular/angular-1.6.7/angular.js"/>
 <script src="../angular/angular-1.6.7/angular-route.min.js"/>

To

 <script src="../angular/angular-1.6.7/angular.js"></script>
 <script src="../angular/angular-1.6.7/angular-route.min.js"></script>

DEMO

 var test= angular.module("myTest", []);
  test.controller("main", ["$scope",function ($scope) {
  $scope.headline = "Its Started";
 }]);
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    
</head>
<body ng-app="myTest">
<div ng-controller="main">
    <h1>{{headline}}</h1>
    {{1+2}}
</div>
</body>
</html>

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

angular-ui-router nested states do not support multiple views functionality

I am struggling to get nested views to work properly. I have a parent view with navigation and content, and when a user clicks on the navigation links, it should load the correct view. However, for some reason, it is still showing the default content. The ...

The data is not visible on the table

I am experiencing some challenges with my MEAN stack website development. I need to display data on a table. routing node.js var Property = mongoose.model('Property'); var Schema = mongoose.Schema; var ObjectId = ...

Restricting data display in AngularJS with $http and get()

Utilizing the $http service and itsget() method, I am able to access data from the database. Within the database there are 100 records organized in an array of objects; however, I am only interested in obtaining the first 10 records rather than all 100. H ...

Output the following by using the given format: *a* -> *a1**aabbbaa* -> *a2b3a2*

I am a beginner in JavaScript. Could you please explain how to achieve the following output? * "a" -> "a1" * "aabbbaa" -> "a2b3a2" I attempted using a hash map, but my test cases are failing. Below is the code I have writt ...

Issue with page refreshing not functioning on localhost in Rails and AngularJS collaboration

I recently encountered a strange issue while working on my Rails 4.2 + AngularJS 1.5 project. Whenever I attempt to refresh (F5) the main web-page, there's about a 9 out of 10 chance that the refresh doesn't happen correctly. In these cases, all ...

AngularJS directive to scroll an image to the top of the sidebar

I am facing an issue in my AngularJS project where I need to scroll the active image to the top. However, when I tried using the element[0].offset() method, it threw an error. Let me explain the situation: In my code, I have hardcoded the active element ...

How to utilize variables in Angular module functions?

My experience with Angular is fairly new, and I recently encountered a debugging issue in my application that unfolded like this: Imagine I am adding a new directive to an existing module defined in another .js file. When I tried using the syntax below: ...

Issue with Angularjs not saving data in a specific field

I've encountered an issue trying to save data in the name field. Even though the POST request runs without any errors, the MongoDB collection only shows the _id and _v fields being updated. To put it simply, I'm unable to successfully save data ...

How to effectively utilize TypeScript in a team environment using both Atom and VSCode?

Our team utilizes TypeScript with both Atom and VSCode as our editors, but we are facing challenges with the tsconfig.json file. VSCode is not recognizing the typings, causing the namespace for 'ng' (for Angular 1.x) to be unknown in VSCode. Wh ...

Creating a jquery DataTable from HTML generated by angular $sce can be done by following these steps

I have created an Angular controller that takes data and generates an HTML table from it. The generated table is being displayed on the page. Now, I want to apply jQuery data tables using that scope variable. The variable contains the HTML code of the tabl ...

Using Angular's ng-repeat directive to iterate over an array from JavaScript

I am attempting to display an array in the HTML HTML: <div class="personWrapper" ng-repeat="message in messages"> <p>{{message}}</p> </div> JS: var app = angular.module('matcherApp', [ "ngRoute", "ngStorage" ] ...

AngularJS Unveiled: The Puzzle of ng-if's Digest Loop

I am experiencing an issue with an infinite loop when loading the view. The data is retrieved from an API using ngResource in the controller. The view is being rendered multiple times before displaying correctly. I suspect that there may be a loop occurrin ...

Should ASP.NET MVC and Azure web roles be combined or kept separate?

In the world of ASP.NET MVC 5 web applications hosted on Azure, my setup includes: web role 1: a visually appealing ASP.NET MVC project utilizing AngularJS and bootstrap for UI web role 2: an ASP.NET MVC Web Api project responsible for API controllers, a ...

Browse through different states by clicking on the <a> </a> tag

Is there a way to switch between states defined by $stateProvider when clicking on the <a> </a> tag? Below are the states I have set up: $stateProvider //region page States .state('page1', { url: "/pg1", ...

Is it possible to invoke a JavaScript function from an Angular controller?

I am working on an Angular controller that displays a Google Map using NgMap. I can add markers to the map by clicking on it, which opens an infoWindow with a link to a JavaScript function. The issue I am facing is that I need to reference Angular methods ...

Organizing string enum in Typescript and AngularJS - Tips and Tricks

In my Typescript file, I have defined an enum called PriorityLevel: enum PriorityLevel { High = <any>'High', Normal = <any>'Normal', Low = <any>'Low'} In the HTML section, I have the following code: <b ...

Looking for assistance in resolving performance problems with numerous elements in AngularJS

I am currently experiencing performance issues with AngularJS, particularly when a large number of "elements" are added to the page. It is taking around 20 seconds for my computer to render the elements in this folder structure. Each folder contains 10 sub ...

Using conditional statements in AngularJS, you can check multiple conditions using the

I am attempting to utilize angular in my slim file, but I'm uncertain how to convert an if else block into angular syntax. Although I am aware that angular does not support ng if else statements, is there a method to modify the code below to work with ...

AngularJS does not provide access to child scope forms within the parent scope when using the ng-switch directive

How can I access the AT model object written in ng-switch? When using ng-switch, a child scope is created and the form exists on this scope. This means that the child scope form will not be available on the parent scope. Can someone please assist me with ...

In AngularJS, modifying the value of a copied variable will result in the corresponding change in the value of the main

I'm facing a peculiar issue. I have an array of objects and I used angular.forEach to update the price key value of each object. However, when I make changes in each object, it also affects the main array object. Take a look at the code snippet below ...