Итак, я получил этот проект, над которым я работаю, я успешно добавляю текст (фишки) в строку, но когда я его удаляю, текстовое значение все еще там. Так что что-то не так в части удаления моего кода. Мне нужна помощь в удалении строки и ее решении!
Мой наставник говорит, что мне нужно добавить изменения в код, чтобы я мог удалить строку из типа и заставить ее работать. (между этими двумя кодами)
let type = this.editDeliveryOrderForm.value.type;
// remove the string from type
this.editDeliveryOrderForm.patchValue({
type
});
add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
console.log(`mat chip`, event);
console.log(`mat chip value`, value);
// Add our fruit
if ((value || '').trim()) {
this.fruits.push({name: value.trim()});
console.log(`fruits`, this.fruits);
let type = this.editDeliveryOrderForm.value.type;
type += ',' + value.trim();
this.editDeliveryOrderForm.patchValue({
type
});
}
// Reset the input value
if (input) {
input.value = '';
}
}
remove(fruit: Fruit): void {
const index = this.fruits.indexOf(fruit);
if (index >= 0) {
this.fruits.splice(index, 1);
let type = this.editDeliveryOrderForm.value.type;
// remove the string from type
this.editDeliveryOrderForm.patchValue({
type
});
}