$injector.modulerr problem

After spending a considerable amount of time analyzing every line of code, I can't seem to pinpoint any errors. Here is what I have:

HTML:

<body ng-app='myApp'>
<div class="wrapper">
  <nav>
    <ul ng-controller="pathController">
      <li ng-click="changePath('about')"><a href="#about">About</a></li>
      <li ng-click="changePath('contacts')"><a href="#contacts">Contacts</a></li>
      <li ng-click="changePath('login')"><a href="#login">Log In</a></li>
      <li ng-click="changePath('register')"><a href="#register">Join Now</a></li>
    </ul>
  </nav>
</div>
<script src="node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script>
<script src="node_modules/angular/angular.min.js" type="text/javascript"></script>
<script src="node_modules/angular-route/angular-route.min.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<script src="scripts/controllers/pathController.js" type="text/javascript"></script>
</body>

app.js:

var app = angular.module("myApp", ['ngRoute', 'ngController']);

app.config(["$locationProvider", "$routeProvider"], 
  function($locationProvider, $routeProvider) {
  $locationProvider.hashPrefix("");
  $routeProvider.when('/', {
    templateUrl: "index.html"
  })
})

I later added the 'ngController' dependency while troubleshooting various things that might solve the issue.

and pathController.js:

app.controller('pathController', function($scope) {
  $scope.changePath = function(pth) {
    window.location.pathname = pth;
  }
})

From my observation, it seems like $routeProvider is not causing the problem. Could you please review and assist in resolving this issue?

P.S. I forgot to mention the error I am encountering in the content, but I highlighted it in the title. Here it is:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.7.4/ ...

Your help is greatly appreciated!

Answer №1

Give it a shot:

var app = angular.module("myApp", ["ngRoute"]);

app.config(["$locationProvider", "$routeProvider", 
 function($locationProvider, $routeProvider) {
 $locationProvider.hashPrefix("");
 $routeProvider.when('/', {
    templateUrl: "index.html"
 })
 }]
)

A mistake has been made:

app.config(["$locationProvider", "$routeProvider"], <-- this ] bracket shouldn't be closed here.

Here is the operational plunkr

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

Encountered an error while attempting to load resource: the server returned a 404 (Not Found) status code when trying to load an image in an

I am looking to dynamically load an image when it is selected from a file picker dialog. The code provided below attempts to achieve this, however, the image does not load into the img tag. <script src="https://cdnjs.cloudflare.com/ajax/libs/jq ...

Anticipating the completion of multiple observable subscription functions

Is there a way to replace and convert all words in an array using an object's method that returns an observable? I found a helpful solution on this post which uses bind to pass the correct value. After all subscriptions are complete, I want to execut ...

angular: setting default selected items in dynamically generated options

After looking at the example provided here, I noticed that all three select options have the same value. How can I ensure that each option has a different selected value? This is what I currently have: <li ng-repeat="tarea in tareas"> <inp ...

What steps can I take to guarantee that a select change event occurs following the setting of ngmodel in Angular2?

I am facing an issue with a select element wherein a basic (change) handler is attached along with an ngmodel. Whenever an <option> with a ng value is set, the change handler triggers before the [(ngModel)] reflects the new values. <div> ...

Adjust the height of a div using jQuery animate based on the amount of text within

I have created a basic animation feature where users can click on an expanding box. I am looking for a solution that does not involve using a plugin. Currently, the code looks like this: $('#one').css("height", "22"); $('#t1').cli ...

Transmitting information through socket.emit from the client to the server

I'm facing an issue while trying to send numeric data from the client to the server using socket.emit. The problem is that the server doesn't seem to be receiving any data, as only `null` gets logged or I might be doing something wrong in my appr ...

JS Issue with Generating Content

Introduction( kind of :) ) Starting with the process of generating 5 coffee beans for each cup of coffee. The coffee class includes a strength attribute, and my goal is to visually distinguish the coffee beans which have a strength greater than the select ...

Xpath-Utilizing a variable within an XPATH expression is necessary

Currently, I am utilizing Selenium-webdriver and facing an issue while trying to select an element based on its "text" using xpath. Since the value is subject to change, I am utilizing a variable. I am looking for a solution to resolve this problem or an a ...

Tips for incorporating 'and' in the 'on' clause of 'join' in knex.js

I need assistance implementing the following SQL code in knex.js: select c.id,c.parent_id,c.comment,u.username,c.postid from comments as c join post_details as p on (p.id = c.postid and c.postid=15)join users as u on (u.id = c.userid); I attempt ...

Learning the best practices for incorporating publish and subscribe in Meteor JS is crucial for achieving efficient

I need some guidance on my implementation of publish and subscribe in Meteor JS. I am new to this and seeking help to ensure that I am doing it correctly. If you require more information about my code, I am happy to provide additional source code. Despit ...

Perform a jQuery function and SQL query when a selection is made in a dropdown menu

Struggling to execute a SQL query on drop-down menu selection. Here's my current code: <script> $('#templateid').change(function(DoUpdateOnSelect) { $.post('page.edit.php?page_id=(-->Need help in retrieving this id from the pa ...

Exploring connections among Array Objects on a Map

Here are some JSON examples of Pokemon Battles: [ { "battleID": "1", "trainers": [ { "LastName": "Ketchum", "ForeName": "Ash" }, { "LastName": "Mason", ...

Setting up a new folder in the internal storage within a React Native Expo environment

In my React Native Expo project, I am utilizing two functions to store data in a JSON file and then save the file to internal storage. However, the code currently asks for permission to store inside a chosen folder, but does not create the "ProjectName" fo ...

Develop a Rails object using AJAX and JavaScript

Within a music application built on Rails, I am attempting to monitor plays for tracks by artists. This involves creating a unique play object each time a visitor plays a track on the site. These play objects are assigned their own distinct IDs and are ass ...

Attempting to invoke a function containing a promise in Javascript

Calling the function numberOfRedeems(dealId) from another function named setUpData raises an issue where the numberOfRedeems() function, which includes a promise and returns "counter", always returns as undefined when executed within the setUpData function ...

retrieve data from an asynchronous request

Utilizing the AWS Service IotData within an AWS Lambda function requires the use of the AWS SDK. When constructing the IotData service, it is necessary to provide an IoT endpoint configuration parameter. To achieve this, another service is utilized to obta ...

Discover how to efficiently load and display a JSON array or object using JavaScript

I am new to learning about json and d3, having just started a few hours ago. While I have basic knowledge of javascript, I need help with loading a json file and displaying all the arrays and objects on the console using d3. I tried to do it myself but unf ...

Can an element be dynamically bound and unbound upon clicking a button in AngularJS?

After creating a display text and an input field, I bound them together using ng-model in the code below: HTML <div ng-app ng-controller="test"> <div ng-bind="content"></div> <input id="txtElem" type="text" ng-model="content" ...

Basic node.js server that responds with HTML and CSS

I have successfully created a basic http server to send an HTML file as a response. However, I'm struggling with how to also send a CSS file so that the client can view the HTML page styled with CSS in their browser. Here is my current code: var htt ...

Performing additional ajax requests in an angularJs application

Is there a way to execute sequential ajax calls in angularJs from within a service? I attempted the following approach: var requests = [ {'url': 'call1'}, {'url': 'call2'}, {'url': 'call3 ...