I have an event array and another team array, I need to match them by event = team []. Medical Teams. []. Eq and get the amount in relation to the selected team.
The multiselect gives me these values:
["Equipo", "Data"]
The arrangement with which I have to validate and extract the amount of that equipment is:
[
{
"equipo": [
{
"eq": "Equipo",
"monto": "1000"
} ,
{
"eq": "Data",
"monto": "200,00"
}
] ,
"_id": "5d9eb311efa054e57755842d",
"nombre": "Equipos Médicos",
"__v": 24,
"codigo": "IUYIUEIUG-984729"
} ,
{
"equipo": [
{
"eq": "EM1",
"monto": "10,00"
} ,
{
"eq": "EM2",
"monto": "20,00"
} ,
{
"eq": "EM3",
"monto": "30,00"
}
] ,
"_id": "5da89260ec2d620ab8fae605",
"nombre": "Especialidad 2",
"codigo": "UYTDUWETVUW-87643",
"__v": 1
}
]
It has to result in its amount... Expected result:
[1000, 200]
Code try in component.ts:
multiEQ(e) {
console.log('e: ', e);
let elementByService = [];
this.equiposMedicosService.getAll().subscribe(em => {
console.log('em: ', em);
em.map(i => {
elementByService.push(i);
});
});
console.log('elementByService: ', elementByService);
}
Code in component.html:
<div class="container text-theme">
<div class="col-12">
<table class="table table-hover text-theme">
<thead>
<tr>
<th>Acción</th>
<th>Clínica u Hospital</th>
<th>Piso</th>
<th>Consultorio</th>
</tr>
</thead>
<tbody formArrayName="clinica">
<tr *ngFor="let item of resourceForm.get('clinica').controls;let i = index">
<ng-container formGroupName="{{i}}">
<td (click)="deleteClinica(i)">
<i class="fa fa-trash pointer" style="color:red"></i>
</td>
<td>
<nb-select formControlName="clc"
class="w-100"
size="small">
<nb-option *ngFor="let clinica of clinicas" [value]="clinica._id">{{ clinica.nombre }}</nb-option>
</nb-select>
</td>
<td>
<input type="number"
class="form-control text-theme text-right"
formControlName="piso"
min="0"
required/>
</td>
<td>
<input type="text"
class="form-control text-theme text-right"
formControlName="consultorio"
required/>
</td>
</ng-container>
</tr>
<tr>
<td (click)="addClinica()">
<i class="fa fa-plus pointer" style="color:green"></i>
</td>
</tr>
</tbody>
</table>
</div>
</div>