angular.js - angular error after gulp compression
滿天的星座
滿天的星座 2017-05-15 17:12:41
0
4
880

There are the following files from bower, as follows

After gulp merge and compression

Run correctly if not compressed. Does anyone have the same problem after using the above dependency compression? How to troubleshoot this problem?

滿天的星座
滿天的星座

reply all(4)
黄舟

If you want to use abbreviations, add the gulp-ng-annotate plug-in to the gulp process.
var ngAnnotate = require('gulp-ng-annotate');

gulp.task('useref-ftl', function () {
    return gulp.src(*******)
        .pipe(gulpif('*.js', ngAnnotate()))
});

The following is the principle:
Dependencies are found by strings. When writing, take the initiative to write the dependencies without abbreviating them.
For example, the formal writing method is
angular.module('adminApp').controller('TestCtrl', ['$scope',function($scope) {}])
Then generally you can abbreviate it to
angular.module(' adminApp').controller('TestCtrl', [function($scope) {}])
But the abbreviated method will report an error after compression and merging.

巴扎黑

Has the reference path changed after compression

某草草
var myModule = angular.module('myApp', []);
    myModule.controller('myCtrl', ['$scope', 'Project', function($scope, Project) {

    }]);
  var myModule = angular.module('myApp', []);
    myModule.controller('myCtrl', , function($scope, Project) {

    });
    没加方括号压缩后可能有问题
phpcn_u1582

Dependencies are found based on strings. When writing, you take the initiative to write the dependencies, because variables and other things will change after compression, and Angular cannot find it by itself.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template