-1

I am having a problem with Angular JS receiving an error Uncaught Error: [$injector:modulerr].... this my javascript and html code.. what's wrong there?

(function(){            

var app = angular.module('store', []);
app.controller('tes', function($scope) {

});

})();  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Angular</title>
</head>
<link rel="stylesheet" type="text/css" href="../bootstrap.css">
<script type="text/javascript" src="../angular.min.js"></script>

<body ng-app = 'store'>
    <div ng-controller="tes">
         <h1>{{ 4 + 4 }}</h1>
    </div>
</body>
</html>
Phil
  • 157,677
  • 23
  • 242
  • 245
Widada
  • 575
  • 2
  • 4
  • 17
  • 1
    what file is that JavaScript in? I don't see any reference to another `.js` in your HTML.... – Claies Apr 30 '15 at 01:17
  • 1
    possible duplicate of [AngularJS 1.2 $injector:modulerr](http://stackoverflow.com/questions/18287482/angularjs-1-2-injectormodulerr) – Deividi Cavarzan Apr 30 '15 at 02:19

4 Answers4

1

I just tested your code by copy paste in a new project and added correct reference to the angular js file and it worked fine for me. Do you have any other module which is trying to load? click on the error link and you might be able to figure out the issue. I think you are missing the correct reference to the angular.min.js file

Mahesh Kava
  • 773
  • 5
  • 16
1

Well you have your script tag hanging outside head tag and before body tag.

Fixed it as follows;

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Angular</title>
</head>

<body ng-app = 'store'>
    <div ng-controller="tes">
         <h1>{{ 4 + 4 }}</h1>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
    <script src="script.js"></script>
</body>
</html>

working link : http://plnkr.co/edit/tLt22vN1mkGDWTNabq3J?p=preview

km1882
  • 740
  • 5
  • 22
0

Most likely explanations

  • You haven't loaded the file where you define the module 'store', the first code block, in the html
  • There's an error in your module code so that angular doesn't interpret it correctly

Also fix the ng-app attribute:

<body ng-app="store">
Peter Ashwell
  • 4,292
  • 2
  • 18
  • 22
0

Please remove (function(){ from top and remove })(); from bottom. it's not a jquery, so please remove it.

And please check ../angular.min.js is on proper place or not.