2017-04-25 84 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