0

I am running simple hello world program (using AngularJS 1.6) from localhost on my ubuntu 17.04, localhost address is http://localhost/js/angular/4/ and the program is not working in Google Chrome, the same code runs all fine on Firefox, and if I rename the same folder to another number or if I keep the same code in another folder, it seems to be working all fine. What could be the reason of this weird behavior as I couldn't find anything similar to this on Internet while searching for the solution.

var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
    $scope.message = "Hello World";
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">

<div ng-controller="myCtrl">
{{ message}}
</div>

</body>
</html>

1
  • what do you get in console/screen/logs? Commented May 10, 2017 at 17:08

1 Answer 1

1

ng-app and ng-controller can't be on the same element.

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

5 Comments

sorry, corrected it in the question, it is indeed on different elements in actual code. Thanks for pointing out.
The example is working fine above when selecting Run code snippet if it isn't running for you on your local, make sure all your files are loaded and you don't have any weird console errors. Short of that everything looks good.
thanks for replying again, but that is the case, the code is running on codepen, firefox and even on chrome if I am running the file directly, but it isn't running using localhost, and isn't giving any errors as well.
Are all the correct versions of your files being loaded?
Yes sir, they were all correctly loading, It seems to be working all fine after restarting apache. Thank you for helping along. :)

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.