michtan
michtan

Reputation: 59

Angular 1.2.26 [$injector:nomod] only on minified version

I have the following HTML:

<!DOCTYPE html>
<html lang="en" >
    <head>
        <title>Title</title>
        <script src="Scripts/angular.min.js"></script>
    </head>
    <body>        
        Hello World
    </body>
</html>

and is giving me the following exception:

0x800a139e - JavaScript runtime error: [$injector:nomod]      
http://errors.angularjs.org/1.2.26/$injector/nomod?p0=ngLocale

If I switch to the non-minified angular.js, the error goes away

Upvotes: 0

Views: 586

Answers (1)

Dima Grossman
Dima Grossman

Reputation: 2830

It is hard to say without looking at your javascript file.

Usually the problem is that angular's dependency system uses function arguments with the default syntax.

for example:

app.controller('mainController', function($scope) {
  $scope.data= 'data';  
});

becomes: app.controller("mainController",function(e){e.data="data"});

In order to avoid this situations you have to use the following syntax

app.controller('mainController', ['$scope', function($scope) {
    $scope.data= 'data!';   
}]);

So the minification script will not change the dependencies name.

You can read more at https://docs.angularjs.org/tutorial/step_05 scroll down to A note on minification

Upvotes: 2

Related Questions