角度安全缩小

Angular safe minification

本文关键字:缩小 安全      更新时间:2023-09-26

我正在以以下方式编写指令:

  • Directive.html(模板(
  • js(控制器(
  • 指令.js(指令(

DirectiveController.js:

function DirectiveController($scope) {}

导演.js:

someModule.directive('directive', function() {
    return {
        restrict: 'E',
        templateUrl: 'Directive.html',
        controller: DirectiveController,
        scope: {
            data: '='
        }
    }
});

问题是,如何缩小DirectiveController?我不能使用:

someModule.controller('someController',['$scope', function($scope) {} ]);

提前感谢

使用$inject"annotation":

DirectiveController.$inject = ['$scope'];
function DirectiveController($scope) {
    ...
}

是的,可以将"annotation"放在函数之前。