AngularJS 1.2.1 $ injector: modulerr after minimization, but it works long before minimization

I searched around. Some people run into this problem because they forgot to enable certain modules, such as ngRoute or ngAnimate ... I have included and entered them.

I use Yeoman to download the project, and the application starts long before the minimization, which is done using the "grunt server"

and after minimizing (when I run "grunt server: dist"), I ran into this problem:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=app&p1=Error%3A%20%…0(http%3A%2F%2Flocalhost%3A9000%2Fscripts%2Fd3a6bda4.vendor.js%3A1%3A11551) d3a6bda4.vendor.js:1

Any idea on this? Thanks in advance.


@tschiela, thanks for inviting me to take a look at Gruntfile.js, but I think that everything should be fine, since I use AngularJS (1.0.8) along with my other projects, and I use the same Gruntfile.js through projects.

@Gorgi Rankovski, thanks for inviting me to take a look at my code, here is the code I use CoffeeScript, I think I got what you mean,

`` `CoffeeScript

angular.module('app.controllers', [])

.controller('AppCtrl', [
    '$scope', '$location'
    ($scope, $location) ->
        $scope.isSpecificPage = ->
            path = $location.path()
            return _.contains( ['/', '/index-vendor', '/404', '/signin', '/signup'], path )
])

`` ``

+4
source share
2 answers

Finally, I have earned.

<!-- build:js scripts/vendor.js -->
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-resource/angular-resource.min.js"></script>
<script src="bower_components/angular-animate/angular-animate.min.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.min.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.min.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="bower_components/underscore/underscore-min.js"></script>
<!-- endbuild -->

I tried a lot of things, finally I found that this has something to do with the grunt-contrib-uglify task. (still the same task works well when I use AngularJS 1.0.8, weird)

So, I did not guess the AngularJS files, instead I just perform the concat task , delete the uglify step, now everything is in order.

useminPrepare: {
  html: '<%= yeoman.app %>/index.html',
  options: {
    dest: '<%= yeoman.dist %>',
    flow: {
      steps: {
        'js': ['concat']
      }
    }
  }
},
0
source

"" . Angular , . Angular script. . : https://www.youtube.com/watch?v=ZhfUv0spHCY

0

All Articles