2017-04-25 65 views
0

我已经用CJS格式编写了我的angularjs应用程序,并使用gulp-systemjs-builder将它们捆绑到一个文件中。使用gulp-ng-annotate和gulp-systemjs-builder

我想输出到DI的gulp-ng-annotate,但它失败了,因为systemjs-builder在\* @ngInject *\和函数声明之间插入了几行。

例子:

包前:

/* @ngInject */ 
function ReportCtrl($scope) { 
    var _ctrl = this; 
} 

捆绑后:

/* @ngInject */ 
var global = this || self, 
    GLOBAL = global; 
function ReportCtrl($scope) { 
    var _ctrl = this; 
} 

任何人都可以建议我怎么能得到过这个问题?

回答

0

https://github.com/olov/ng-annotate

找到了解决办法,而不是使用评论/* @ngInject */的,我不得不使用字符串作为"ngInject";我的函数声明之后的第一行。这种方式gulp-systemjs-builder没有搞乱顺序和ng-annotate可以成功注释的功能。的

因此,而不是写这个 -

/* @ngInject */ 
function ReportCtrl($scope) { 
    var _ctrl = this; 
} 

我不得不写这 -

​​3210