[英]TSLint returns expected an assignment or function call
I am checking my angular project with tslint, and I am getting this error from which I don't understand the reason. 我正在用tslint检查我的Angular项目,但是却收到了我不明白原因的错误。 The error is: expected an assignment or function call
错误是:预期分配或函数调用
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
this.loading = false;
this.printingOrders = response.data;
this.totalNumberOfCharacters = 0;
this.totalNumberOfCharactersNext = 0;
if (this.printingOrders.labelPresentOrder && this.printingOrders.labelPresentOrder.lines) {
this.printingOrders.labelPresentOrder.lines.forEach(
line => {
this.totalNumberOfCharacters += line.length;
}
);
}
if (this.printingOrders.labelNextOrder && this.printingOrders.labelNextOrder.lines) {
this.printingOrders.labelNextOrder.lines.forEach(
line => {
this.totalNumberOfCharactersNext += line.length;
}
);
}
if (this.printingOrders.printing) {
this.suscribeNotifications();
}
}
), err => {
this.loading = false;
this.alertService.error(INFO_NO_EXISTEN_ORDEN_PREPARADA);
this.hasAlert = true;
};
} }
The error is in this line: 错误在这一行:
this.imprimirService.getInfoPrinting().subscribe(
What am I doing wrong? 我究竟做错了什么?
Thanks. 谢谢。
Your code is incorrect. 您的代码不正确。 Instead of
代替
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
...
}
), err => {
...
};
}
It should be 它应该是
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
...
},
err => {
...
});
}
The error would be much easier to spot if the method body was shorter. 如果方法主体更短,则错误将更容易发现。 You should delegate to a separate method inside your callback.
您应该在回调中委派一个单独的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.