我已经用CJS格式编写了angularjs应用程序,并使用gulp-systemjs-builder
将它们捆绑到一个文件中。
我正在尝试将输出通过管道输出到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 :(得分:0)
在https://github.com/olov/ng-annotate
中找到解决方案我不得不使用注释 private StreamReader SR;
private string File1;
public override void AcquireConnections(object Transaction)
{
// Get the connection for File1
IDTSConnectionManager100 CM = this.Connections.OILFILEMGR;
File1 = (string)CM.AcquireConnection(null);
}
public override void PreExecute()
{
// Create a reader for File1
base.PreExecute();
SR = new StreamReader(File1);
}
public override void PostExecute()
{
// Close the reader
base.PostExecute();
SR.Close();
}
public override void CreateNewOutputRows()
{
// Declare variables
string nextLine;
int LineNumber;
nextLine = SR.ReadLine();
LineNumber = 1;
while (nextLine != null)
{
//MessageBox.Show(nextLine);
// Add a row
Output0Buffer.AddRow();
Output0Buffer.APINumber = nextLine.Substring(5, 6);
Output0Buffer.County = nextLine.Substring(2, 3);
Output0Buffer.District = nextLine.Substring(14, 2);
nextLine = SR.ReadLine();
LineNumber = LineNumber + 1;
while (nextLine.Substring(0, 2) != "01")
{
if (nextLine.Substring(0, 2) == "02")
{
Output0Buffer.LeaseNumber = nextLine.Substring(5, 5);
}
if (nextLine.Substring(0, 2) == "09")
{
Output0Buffer.FormationName = nextLine.Substring(5, 32);
}
if (nextLine.Substring(0, 2) == "13")
{
Output0Buffer.Latitude = nextLine.Substring(132, 10);
Output0Buffer.Longitude = nextLine.Substring(142, 10);
}
nextLine = SR.ReadLine();
LineNumber = LineNumber + 1;
}
}
}
}
,而是在函数声明之后使用字符串/* @ngInject */
作为第一行。这种方式"ngInject";
没有弄乱排序,gulp-systemjs-builder
可以成功地注释函数。
所以不要写这个 -
ng-annotate
我不得不写这个 -
/* @ngInject */
function ReportCtrl($scope) {
var _ctrl = this;
}