1

有没有办法在不破坏代码的情况下实现这一点?我试过 mangleProperties 但我的代码确实不起作用,即使在使用正则表达式和“控制器作为”功能(https://daveceddia.com/convert-scope-to-controlleras/)之后也是如此。

gulp.task('useref', ['ng_annotate2'], function (done) {
  gulp.src('./www/index.html')
    .pipe(useref())
    .pipe(gulpif('*.js', uglify({
      mangleProperties: {
        regex: /something$scope/
      }
    })))
    .pipe(gulpif('*.css', minifyCss()))
    .pipe(gulp.dest('./www/dist'))
    .on('end', done);
});
4

1 回答 1

0

如果您像这样在隐式注释中定义您的控制器

someModule.controller('MyController', function($scope, greeter) {
  // ...
});

那么你不能缩小你的代码。

所以使用 Inline Array Annotation 像这样定义你的控制器

someModule.controller('MyController', ['$scope', 'greeter', function($scope, greeter) {
  // ...
}]);

有关更多信息,请阅读此依赖注入

于 2016-07-04T06:11:25.297 回答