`Angular routing problem, MEAN Stack routing not functioning correctly`

In my routes.js file, I have set up various routes for different pages like submit.html and schedule.html. However, I encountered an issue where angular routing does not work properly when using app.get('*'). This meant that any request would default back to index.html even if the URL had changed.

module.exports = function(app) {
    app.get('/submit', function(req,res){
        res.sendfile('./public/submit.html');
    }); 

    app.get('/schedule', function(req,res){
        res.sendfile('./public/schedule.html');
    }); 

    // Other route configurations...

    app.get('/', function(req, res){
        res.sendfile('./public/index.html');
    });
};

In addition to my routes.js, I also have an appRoutes.js file which handles the AngularJS routing. Here is an example:

angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {

    $routeProvider
        .when('/', {
            templateUrl: 'index.html',
            controller: 'LoginController'
        })
        .when('/submit', {
            templateUrl: 'submit.html',
            controller: 'SubmitController'
        });

    $locationProvider.html5Mode(true);

}]);

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

Using JavaScript to switch an already assigned class

I am trying to implement a navigation bar with Bootstrap icons inside the anchor tags. Here is the code snippet: <li class="nav-item"> <a href="#" class="nav-link"> <i class="bi bi-house"&g ...

Why does JavaScript return NaN when combining arrays of different lengths?

Information: Hey, take a look at these 4 arrays, and then there's an array with those arrays nested inside. I'm using _.reduce to calculate the total length of all arrays combined. However, when I run the function with the array of arrays, I&ap ...

Combining sub-arrays in JavaScript into one single array

Upon running the code below, I received the following results: d3.csv("../hello.csv", function(data) { console.log(data); var usable = data.map(function (d) { return { description: d.description.split(" ") }; ...

The error message "Cannot access documentElement property of null in Ajax" indicates a problem with finding the documentElement

After following along with the Ajax tutorial from The New Boston, I encountered an issue where the code I wrote was not working on my computer as expected. When using Google Chrome: Uncaught TypeError: Cannot read property 'documentElement' of ...

Using PHP to generate hyperlink onclick events with jQuery

I am currently dealing with some messy PHP code that needs to be cleaned up at a later time. However, the priority now is to get the code functioning properly. Currently, the post command is not executing, meaning that the script find.php is not being ru ...

Guide to correctly setting up the b-table component in vue-test-utils

Currently, I am utilizing the buefy css library in conjunction with the vue.js framework. The challenge I am facing involves unit testing my vue component (Foo), which includes the b-table component from buefy: <b-table :data="foo" class=&quo ...

Issue with nested state controller not being triggered

I am facing an issue with nested states in my Angular application. The parent state is executing fine, but the child state is not being triggered. The URL structure I am working with is: #/restaurant/2/our-food What I want is for the application to first ...

The ES6 class Inheritance chain does not properly utilize the instanceof keyword

My curiosity lies in understanding why the instanceof operator fails to work properly for the inheritance chain when there are multiple chains of inheritance involved. (optional read) How does the instanceof operator function? When using obj inst ...

Detect word count dynamically with jQuery

I have implemented a jQuery feature that allows me to track word count in real time: $("input[type='text']:not(:disabled)").each(function(){ var input = '#' + this.id; word_count(input); $(this).key ...

What is the most effective method to extract an ID from a URL that is written in various formats?

Does anyone know of a reliable method to extract an ID from various URL formats using javascript or jquery? https://plus.google.com/115025207826515678661/posts https://plus.google.com/115025207826515678661/ https://plus.google.com/115025207826515678661 ht ...

Struggling with State Management in React

I am utilizing an API (in Node) to make a call from my react component (Stats.js) The function getName is taking a prop that is passed in (known as 'value') so it can search for a value in MongoDB. See the code snippet below: /* Stats React Com ...

Convert JavaScript object into distinct identifier

I have a data object where I'm storing various page settings, structured like this: var filters={ "brands":["brand1","brand2","brand3"], "family":"reds", "palettes":["palette1","palette2","palette3"], "color":"a1b2" }; This object is ...

Tips on adding background images to your chart's background

Is there a way to set an image as the background in Lightning Chart using chartXY.setChartBackground? ...

I aim to display a success message upon form submission

Can someone assist me with a problem I'm facing? I need to display a success message after successfully submitting a form. I'm utilizing bootstrap and jQuery for this task, along with an email service known as emailJS. This service enables us to ...

React: Why aren't class methods always running as expected?

I created a class component that retrieves a list of applications from an external API. It then sends a separate request for each application to check its status. The fetching of the applications works well, but there is an issue with the pinging process ...

Switch between divs using an update panel

Consider this scenario: Numerous div controls are present on an aspx page, and update panels are being used to prevent page refresh. These divs contain various controls like buttons and textboxes: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> ...

scrollIntoView() causes the entire page to move

Compatibility: Tested on Firefox 16/27 and Chrome 33 In my current project, I am facing an issue with a <div> element that has scroll functionality and contains numerous nested <p> elements. The problem arises when I try to use the scrollInto ...

Are there any alternatives to using the $size function in MongoDB for this specific tier in Atlas?

I am trying to create a code that will return certain data only if there are exactly 2 instances of the by field in the data array. The number of _id entries can vary. Unfortunately, using { $size: { data: 2 }, } doesn't work as I am encountering an ...

Switch Background Image - The image failed to display

Here is the code snippet I am currently working with. It involves displaying a background-image when clicking on a link with the class 'home-link', and not showing an image if the link does not have this class. The issue at hand: The problem ari ...

Understanding the relationship between jQuery selector elements and jQuery objects

As part of my journey to understand jQuery and its core functionality, I am developing a tiny library/framework. I am intrigued by how jQuery selector elements are returned as jQuery objects with all the associated methods. Take this example: $('ul ...