I'm using grunt concat and uglify to minify angular app however the minified script is giving the following error.
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.9/$injector/modulerr?p0=myapp&p1=Error%…2F%2F192.168.1.244%3A8080%2Fapp%2Fdist%2Fjs%2Fmyapp.min.js%3A5%3A10649)(…)
This is how I have implemented DI in the angular application.
(function() {
myapp
.controller('MyController',MyController);
MyController.$inject = ['$scope','$rootScope'];
function MyController($scope,$rootScope) {
}
})();
This is how my gruntfile looks.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: ['node_modules/jquery/dist/jquery.min.js','node_modules/bootstrap/dist/js/bootstrap.min.js','node_modules/angular/angular.min.js'],
dest: 'dist/js/myapp.js',
}
},
uglify: {
options: {
report: 'min',
mangle: false
},
my_target: {
files: {
'dist/js/myapp.min.js':['dist/js/myapp.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
};
I'm following the proper DI method for angular and why's the error still occuring?