【发布时间】:2021-09-11 02:00:20
【问题描述】:
我要数 ItemTotal = 数量 * UnitPrice 和发票总价。请建议我编写正确的方法来计算总计和项目总计。
medicinePurchaseForm: FormGroup;
ngOnInit(): void {
this.initForm();
}
private initForm() {
this.medicinePurchaseForm = new FormGroup({
prescriptionId: new FormControl(),
subtotal: new FormControl(),
purchaseMedicineList: new FormArray([
])
});
}
get medicineArray() {
return this.medicinePurchaseForm.controls.purchaseMedicineList as FormArray;
}
addMedicinetoLine(){
const purchasemedicine = new FormGroup({
medicineId: new FormControl(this.medicineID.value, Validators.required),
medicineName: new FormControl(this.brandName.value, Validators.required),
unitPrice: new FormControl(this.price.value),
quantity: new FormControl(this.quantity.value, Validators.required),
itemTotal: new FormControl(),
});
this.medicineArray.push(purchasemedicine);
}
【问题讨论】:
标签: angular angular-material angular-forms