Я хочу очистить все поля, когда пользователь меняет Материал.Я поделюсь с вами кодом.Измененный материал вызывает проблемы, такие как значение не определено.
// on material changed //
materialChanged(event: { component: SelectSearchableComponent, value: any }) {
//material selected
console.log('event: ', event);
if (event) {
this.temporaryUnit = event.value.unit.value;
}
// additem function //
addItem() {
const found = this.ListOfUsedMaterials.find(item =>
item.goodId == this.selectedGood.id && item.device == this.deviceTypId);
if (found) {
found.quantity += Number(this.item.quantity);
this.item.quantity = "";
this.selectedGood = "";
} else {
this.ListOfUsedMaterials.push({
title: this.selectedGood.value,
quantity: Number(this.item.quantity),
goodId: this.selectedGood.id,
unit: this.selectedGood.unit,
device: this.deviceTypId,
manufacturer: this.deviceManufacturerId,
mark: this.deviceMark
});
this.onClear(event);
}
}