我以CJS格式编写了我的angularjs应用程序,并使用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;
}有谁能建议我如何克服这个问题吗?
发布于 2017-04-27 12:21:47
在https://github.com/olov/ng-annotate中找到了解决方案
我不得不使用字符串/* @ngInject */作为函数声明后的第一行,而不是使用注释"ngInject";。这样,gulp-systemjs-builder就不会打乱排序,并且ng-annotate可以成功地对函数进行注释。
所以与其写这个-
/* @ngInject */
function ReportCtrl($scope) {
var _ctrl = this;
}我不得不写这个-
function ReportCtrl($scope) {
"ngInject";
var _ctrl = this;
}https://stackoverflow.com/questions/43605042
复制相似问题