我正在VSC中运行一个代码,在Windows中运行了angular 8,但是已经检查了该代码,添加了“,”,然后使用了“”代替“”(这是TS的建议),但仍然无法正常工作,请双击检查,但我不知道出了什么问题,谢谢您的帮助。
src / app / crud / stock / stock.service.ts:31:3中出现错误-TS1005错误:“,”预期。
31} 〜
我「wdm」:编译失败。
import { Component, OnInit } from '@angular/core';
import { IProduct } from '../../entities/product';
import { FormBuilder } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { StockService } from './stock.service';
import { IStock } from '../../entities/stock';
import { ProductService } from '../product/product.service';
@Component({
selector: 'app-stock',
templateUrl: './stock.component.html',
styleUrls: ['./stock.component.css'],
})
export class StockComponent implements OnInit {
ngOnInit(): void {
this.refreshData();
setInterval(() => {
this.refreshData();
}, 1000);
}
checkoutForm;
products: IProduct[] = []
stock: IStock = null;
stockService: StockService;
productService: ProductService;
message = ''
stocks: IStock[] = [];
accion = 0
title_accion = 'Salvar'
constructor(private _stockService: StockService, private _ProductService: ProductService,
private formBuilder: FormBuilder,
private router: ActivatedRoute) {
this.checkoutForm = this.formBuilder.group({
id: 0,
id_product: '',
cantidad: 0,
description: ''
});
this._ProductService.getProducts().subscribe(data => {
this.products = data;
},
error => console.log('HTTP response', error)
)
}
onSubmit(customerData) {
if (this.accion == 1) {
console.log(customerData);
this.stock = {
id: customerData.id,
id_product: customerData.id_product,
cantidad: customerData.cantidad,
description: customerData.description
};
this._stockService.editStock(this.stock).subscribe(
error => console.log('HTTP response', error)
)
}
else {
console.log(customerData);
this.stock = {
id: customerData.id,
id_product: customerData.id_product,
cantidad: customerData.cantidad,
description: customerData.description
}
this._stockService.saveStock(this.stock).subscribe(
error => console.log('HTTP response', error)
)
}
this.checkoutForm = this.formBuilder.group({
id_product: 0,
cantidad: 0,
description: ''
});
this.accion = 0;
console.log(this.stock);
this.title_accion = 'Salvar';
}
update(customerData) {
this.title_accion = 'Editar';
this.checkoutForm = this.formBuilder.group({
id: customerData.id,
id_product: customerData.id_product,
cantidad: customerData.cantidad,
description: customerData.description
});
this.accion = 1;
this.title_accion = 'Salvar';
}
delete(customerData) {
console.log(customerData);
this.stock = {
id: customerData.id,
id_product: customerData.id_product,
cantidad: customerData.cantidad,
description: customerData.description
}
this._stockService.deleteStock(this.stock).subscribe(
error => console.log('HTTP response', error)
)
this.accion = 0;
this.title_accion = 'Salvar';
}
refreshData() {
this._stockService.getStocks().subscribe(data => {
this.stocks = data;
},
error => console.log('HTTP response', error)
)
}
}