0

I am trying a very simple web application using AngularJS, which files you can see here. To run it I have installed node.js and ran "npm install -g http-server" on command prompt (Windows 10), navigated to the folder and then executed "http-server -o". Chrome window opened and everything looked fine, it looked that controller worked fine. At the moment it only returns a word to the variable in index.html. I wanted to make sure that everything really works fine, so I added a tag with word "Hello!" to the index.html and changed controller return word from "success" to "done". Reloaded the website page and I was surprised that I saw "Hello!" and "success", but not "Hello!" and "done". I have closed local server and ran it again, but result coming from controller was still the same. Could someone explain why is this happening and what should I do to get the new result from controller?

index.html is:

<!DOCTYPE html>
<html>
<head>
<title>EventsApp</title>

<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>

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


<body ng-app="EventsApp" ng-controller="HomeController" >
  <header class="container">
    <div class="row">
      <h1 class="col-sm-8">EventsApp</h1>
    </div>
  </header>

<section class="jumbotron">
</section>


<h1>  {{test}}  </h1>
<div ng-view></div>


<!-- Modules -->
<script type="text/javascript"  src="js/app.js"></script>

<!-- Controllers -->
<script type="text/javascript"  src="js/controllers/HomeController.js"></script>

<!-- Services -->

</body>
</html>

HomeController.js is:

app.controller('HomeController', ['$scope', 
 function($scope ) {
    $scope.test="done";
}]);

app.js is:

var app = angular.module("EventsApp", []);
3
  • please post the code here. Commented Mar 22, 2017 at 23:54
  • 2
    a minimal reproducible example at that. Commented Mar 22, 2017 at 23:54
  • I thaught that link to GitHub will be better to see everything, but I am adding code as you asked Commented Mar 23, 2017 at 0:00

1 Answer 1

2

This is most probably not a node.js issue. Your HTML or JS probably stayed cached in your browser and you're still seeing the old code.

Open dev tools in chrome (with F12) and then click the three vertical dots and select "settings".

enter image description here

Then under Settings -> Network enable the "disable cache while dev tools is open" option.

enter image description here

Then hit F5 to refresh the page and this should fetch the latest JS file for you and you should see "done" after that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.