缩小包含自定义过滤器的 AngularJS 脚本
Minifying AngularJS script that includes a custom filter
我研究了三种不同的方法来缩小 AngularJS 脚本。但是,其中 none 解释了我应该如何考虑自定义过滤器。我的代码格式如下:
app.controller("App", ["$scope","$timeout", function($scope, $timeout){...}]);
连同一些像这样的附加代码:
app.filter('unsafe', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
当我缩小以上所有内容时,过滤器不再被识别。我该如何准备我的代码以进行缩小?
app.filter('unsafe', ['$sce', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
}]);
缩小后 $sce 被转换成一个名为 a 的变量,这样它可能需要更少的 space 但 angular 不再识别它所以你需要声明第一个参数仍然是 $sce 但有另一个变量名
我研究了三种不同的方法来缩小 AngularJS 脚本。但是,其中 none 解释了我应该如何考虑自定义过滤器。我的代码格式如下:
app.controller("App", ["$scope","$timeout", function($scope, $timeout){...}]);
连同一些像这样的附加代码:
app.filter('unsafe', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
当我缩小以上所有内容时,过滤器不再被识别。我该如何准备我的代码以进行缩小?
app.filter('unsafe', ['$sce', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
}]);
缩小后 $sce 被转换成一个名为 a 的变量,这样它可能需要更少的 space 但 angular 不再识别它所以你需要声明第一个参数仍然是 $sce 但有另一个变量名