Encountering the AngularJS .Net Core routing $injector:modulerr error

I'm currently learning about .Net Core and AngularJS by following tutorials. However, I've encountered an error while attempting to implement client routing in the newest version of .Net Core with default configuration. The AngularJS error I received was: $injector:modulerr Module Error

To troubleshoot this issue, I created a separate project to focus solely on testing routing. Here is some sample code:

(function () {
'use strict';

angular.module('routeApp', ['ngRoute']).config(config);

function config($routeProvider, $locationProvider) {

    $routeProvider
        .when('/', {
            templateUrl: '/Views/home.html',
            controller: 'HomeController'
        })
        .when('/about', {
            templateUrl: '/Views/about.html',
            controller: 'AboutController'
        })
        .otherwise({
            redirectTo: '/'
        });

    $locationProvider.html5Mode(true);
};
})();

Here are the controllers used:

(function () {
'use strict';

angular
    .module('routeApp')
    .controller('HomeController', HomeController)
    .controller('AboutController', AboutController)
    .controller('ErrorController', ErrorController);

HomeController.$inject = ['$scope']; 

function HomeController($scope) {
    $scope.message = "Welcome homepage";
}

AboutController.$inject = ['$scope'];

function AboutController($scope) {
    $scope.message = "This is about page";
}

ErrorController.$inject = ['$scope'];

function ErrorController($scope) {
    $scope.message = "Error 404!";
}

})();

And here is the index.html file for reference:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>AngularJS Routing App</title>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-route.js"></script>

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

</head>
<body ng-app="routeApp">

    <a href="/">Home</a>
    <a href="/about">About</a>
    <div>
        <ng-view></ng-view>
    </div>

</body>
</html>

Can anyone help me identify what's causing this error? Do I need any specific server configurations?

PS. I'm using Visual Studio 2015 with Update 3.

PS2. Browser stack trace:

Uncaught Error: [$injector:modulerr] Failed to instantiate module routeApp due to:
Error: [$injector:unpr] Unknown provider: a
http://errors.angularjs.org/1.5.6/$injector/unpr?p0=a
...

PS3. Minified app.js

!function(){"use strict";function a(a,b){a.when("/",{templateUrl:"/Views/home.html",controller:"HomeController"}).when("/about",{templateUrl:"/Views/about.html",controller:"AboutController"}).otherwise({redirectTo:"/"}),b.html5Mode(!0)}angular.module("routeApp",["ngRoute"]).config(a)}(),function(){"use strict";function a(a){a.message="Welcome homepage"}function b(a){a.message="This is about page"}function c(a){a.message="Error 404!"}angular.module("routeApp").controller("HomeController",a).controller("AboutController",b).controller("ErrorController",c),a.$inject=["$scope"],b.$inject=["$scope"],c.$inject=["$scope"]}();

Answer №1

Ensure that the application is being executed on a server.

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

Issue: AngularJS not refreshing view after receiving server response

Currently, as I work on developing a mobile application, I've come across an issue related to relaying messages in the view after executing an ajax call and receiving data from the server. My goal is to display these messages to users only after they ...

Optimizing Wordpress by Efficiently Enqueueing Javascript

As a beginner with a WordPress website, I am aware that in order to execute scripts on a WordPress page, they need to be enqueued in the functions.php file. However, I'm unsure about the correct process for this. The specific JavaScript file I want t ...

The functionality for the angular ng-model-options getterSetter is not functioning as expected

I've been trying to utilize the ng-model-options getterSetter feature, but I'm having trouble getting it to execute my model function. <input id="idShowDisabled2" type="checkbox" ng-model="myObj.Trev" ng-model-options="{ getterSetter: true }" ...

What is the method for incorporating an upward arrow into a select element, while also including a downward arrow, in order to navigate through options exclusively with

I have a select element that I have styled with up and down arrows. However, I am seeking assistance to navigate the options dropdown solely using these arrows and hide the dropdown list. Here is the HTML: <div class="select_wrap"> <d ...

Tips for preventing HTTP Status 415 when sending an ajax request to the server

I am struggling with an AJAX call that should be returning a JSON document function fetchData() { $.ajax({ url: '/x', type: 'GET', data: "json", success: function (data) { // code is miss ...

Unable to display nested JSON data from API in Vue.js

Having trouble accessing nested properties from API JSON data. The Vue component I'm working on: var profileComponent = { data : function() { return { isError : false, loading : true, users : null, ...

clicking on internal links in the bootstrap side menu causes it to jump

Im trying to add a side menu to a help page. The menu and internal links are functioning properly, but when clicked, the side menu partially goes behind the navbar. As a beginner, I'm not sure how to resolve this issue. Can someone offer some guidan ...

Utilize GetXmlHttpObject for an AJAX request to interact with a PHP script

I am currently attempting to call a PHP file using the GetXmlHttpObject object and so far, I have had some progress. However, it seems that there is an issue with the URL variable. Do I need to handle the URL string in a different way? Here is the releva ...

How can I fix the position of the close button when using the paper component of a modal in material ui to ensure responsiveness on the screen

I recently created a cards page where multiple cards are displayed. Each card opens a modal component when clicked, but unfortunately, the close button is not functioning properly. Here's an image showing the issue with the button's position whe ...

Tips for creating a filter in React JS using checkboxes

In my current situation, I have a constant that will eventually be replaced with an API. For now, it resembles the future API in the following way: const foo = { {'id':1, 'price':200, 'type':1,}, {'id':2, &apo ...

Next.js encountered an error while trying to locate the flowbite.min.js file for Tailwindcss and Flowbite, resulting in a

I'm having an issue with integrating the flowbite package with TailwindCSS in my Next.js application. Despite configuring everything correctly, I am encountering an error when adding the flowbite.min.js script: GET http://localhost:3000/node_modules/f ...

Utilize flexbox to create a list that is displayed in a column-reverse layout

I am facing a challenge in displaying the latest chat person in the 1st position (active) using Firebase. Unfortunately, Firebase does not have a date field which makes it difficult to achieve this. I have attempted converting the date into milliseconds an ...

AngularJS is failing to set XSRF headers on requests

I'm in the process of creating an application using DJANGO and AngularJS, where the Angular component is not being hosted by Django. I've configured the Angular $httpProvider like this: myApp = angular.module('myApp', []) myApp.confi ...

Export default does not actually yield a function; rather, it returns an object

I recently developed a function that is responsible for importing a script from a specified source, calling its exported function, and handling the returned result. To simplify things, I have streamlined the code to focus solely on returning the result. co ...

Validating complex ASP.NET MVC objects using AngularJS

I am encountering an issue with validating my model in a subform using AngularJS. Despite making changes to the SearchPostCode values and seeing updates in classes, the error message fails to display, and the button remains disabled. <form novalidate&g ...

Ensuring the accuracy of query parameters in REST api calls using node.js

Each object type in the GET request to the API has a set of valid query parameters. var queryFields = { 'organisation': ['limit', 'page', 'id', 'search'], 'actor': ['limit', 'p ...

Issues with data communication in AJAX and Node JS/Express post requests

I'm currently exploring Node.js and I'm running into an issue with app.post. Everything seems to be working fine, as I can see the console log whenever the action is executed. However, the data sent by AJAX from main.js does not seem to be receiv ...

Masquerade as a FormsAuthenticated user within an HttpHandler when making a WCF call

When utilizing HttpHandlers to dynamically generate PDF report files, it is essential to maintain the authenticated user context. In order to create the report PDF file, a method on a secure WCF service needs to be invoked with the caller's context (t ...

Fix the order of the list items with HTML Agility Pack

I've been experimenting with the HTML Agility Pack to convert HTML into valid XHTML for inclusion in a larger XML document. While it mostly works, I've run into an issue with how lists are formatted: <ul> <li>item1 <li> ...

Error: No @Directive annotation was found on the ChartComponent for Highcharts in Angular 2

I'm having trouble integrating Highcharts for Angular 2 into my project. After adding the CHART_DIRECTIVES to the directives array in @Component, I encountered the following error in my browser console: EXCEPTION: Error: Uncaught (in promise): No ...