Я пытаюсь удалить элемент из массива. Элемент должен быть удален динамически.
Вот мой код
Массив
{
"corporateId": "be67e184-a663-439c-b841-c14a734011eb",
"selectedMAP": [
{
"mapId": 79,
"mapName": "discovery",
"active": true,
"options": [
{
"optionId": 116,
"optionName": "comprehensive",
"memberAmount": 2000,
"adultDependantAmount": 1500,
"childDependantAmount": 500,
"active": true
}
]
},
{
"mapId": 80,
"mapName": "goodhealth",
"active": true,
"options": [
{
"optionId": 117,
"optionName": "keycore",
"memberAmount": 1000,
"adultDependantAmount": 600,
"childDependantAmount": 400,
"active": true
},
{
"optionId": 119,
"optionName": "keycore2",
"memberAmount": 500,
"adultDependantAmount": 300,
"childDependantAmount": 200,
"active": true
}
]
}
]
}
TS
removeOption(index: number, indexOption: number) {
this.companyMedicalAidProvider[0].selectedMAP[index].options[indexOption].splice(indexOption, 1);
}
HTML
<div id="medicalCard" class="medicalCard" *ngFor="let provider of companyMedicalAidProvider; let i = index;">
...
<div id="option" class="row option" *ngFor="let providerOptions of companyMedicalAidProvider[0].selectedMAP[i].options; let b = index;">
<button (click)="removeOption(b,i)">X</button>
</div>
...
</div>
Ошибка, которую я вижу в своей консоли: ERROR TypeError: this.companyMedicalAidProvider[0].selectedMAP[index].options[indexOption].splice is not a function