I seem to be encountering a weird issue in a MEAN-stack app: An anchor
link that should be navigating to another page doesn't do so. Instead, it changes the URL in the URL box, but the user has to manually refresh for the new page to show up.
/routes/welcome.js
(Node.JS routing):
var express = require("express");
var router = express.Router();
router.get("/welcome", function(req, res, next) {
res.render("welcome", {title: "Express"});
});
module.exports = router;
/landing.ejs
(This is the main page. User starts from here):
<html>
...
<body ng-app="myapp">
<div ui-view="container" class="head-container">
<a href="/welcome">Login</a>
...
</html>
authController.js
:
var app = angular.module(“myapp.controllers.auth", [
"ui.router"
]);
app.config([
"$stateProvider",
function($stateProvider) {
$stateProvider.state("welcome", {
parent: "root",
url: "/welcome",
templateUrl: "welcome",
controller: "AuthController",
})
}
]);
Assuming the user is at localhost:3000
and is currently looking at the landing.ejs
page. If he/she clicks on the "login" link, the URL in the URL box changes to localhost:3000/welcome
, but the actual page remains the same, as if nothing happened. But when the user right clicks and refreshes the page, it changes to welcome.ejs
. Why do I have to refresh?