Why in the somma
value I've the concatenation of totaleEnergetico
and totaleStrutturale
instead a sum?
RiepilogoCombinatoStComponent.ts
export class RiepilogoCombinatoStComponent implements OnInit {
constructor() { }
interventi: AssociazioneInterventoSt[] = []
arr: number = 0
selezione: number
totaleStrutturale: number = 0
totaleEnergetico: number = 0
somma: number = 0
ngOnInit() {
this.interventi = window.history.state.interventi
console.log(this.interventi)
}
calcola() {
let totaleSt: number
this.interventi.forEach(c => {
this.totaleEnergetico = this.selezione
totaleSt = c.prezzoSupInt
this.totaleStrutturale = totaleSt
})
this.somma = this.totaleEnergetico + this.totaleStrutturale
}
AssociazioneInterventoSt.ts
prezzoSupInt: number
RiepilogoCombinatoStComponent.html
<div class="container">
<div class="card my-5" *ngFor="let el of interventi; index as j">
<div class="card-header" style="text-align: center;">
<div [(ngModel)]="arr" name="fieldName" ngDefaultControl>
INTERVENTO: {{el.intervento.codice}}
</div>
</div>
<div class="card-body">
<div *ngIf="interventi[arr]">
<select class="form-control" [(ngModel)]="selezione">
<option [value]="int.prezzoVista" *ngFor="let int of interventi[arr].associazione; index as i">
{{int.intervento.codice}}
</option>
</select>
<div style="text-align: center; margin-top: 10px;">
<button class="btn btn-outline-default" (click)="calcola()">Ottieni risultato</button>
</div>
<hr>
Costo Strutturale: {{el.prezzoSupInt}}<br>
Costo Energetico: {{totaleEnergetico}}
<hr>
Somma: {{somma}}<br>
Costo Integrato:<br>
<hr>
Risparmio euro:<br>
Risparmio %:<br>
<hr>
Attrezzature per la sicurezza:
</div>
</div>
</div>
</div>