I created a accordion list
. This accordion list
I believe from a json obtained from a post query.
When I have the answer json, I create the accordion list
. I create the first level of the accordion but when deploying it, depending on a value, I show an image or not.
Whether or not I show the image by evaluating a property of a variable. In addition to displaying the image, I call a method that simply calls an alert.
My problem is that the image does show me only once but the alert shows it to me several times ...
My code is as follows:
<label *ngFor="let variable of placa.variablesplaca;" no-padding>
<div *ngIf="variable.magnitud.magnitud === 'final de carrera' && variable.senyal.orden === 1 && variable.valor === 1; else second">
<img src="../../assets/imgs/compuertaabierta.png" style="width: 12vh; height: 20vh"><br>
{{ alertar('Abierta') }}
</div>
<div #second *ngIf="variable.magnitud.magnitud === 'final de carrera' && variable.senyal.orden == 2 && variable.valor == 1; else third">
<img src="../../assets/imgs/compuertacerrada.png" style="width: 12vh; height: 20vh"><br>
{{ alertar('Cerrada') }}
</div>
<div #third *ngIf="variable.magnitud.magnitud === 'final de carrera' && variable.valor == 0">
<img src="../../assets/imgs/compuertasemi.png" style="width: 12vh; height: 20vh"><br>
{{ alertar('Semi') }}
</div>
</label>
In the response of the json I have several "variables" but only 2 whose magnitude is "end of career" with which, I should only enter 2 times the if
but what I see is the following, it shows me 2 times the image, that's perfect, but it shows me the warning many times.
I do not know if I have explained it well, I can explain my case more if it is appropriate or not well understood.