Why is the somma
value showing the concatenation of totaleEnergetico
and totaleStrutturale
instead of 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()">Get result</button>
</div>
<hr>
Structural Cost: {{el.prezzoSupInt}}<br>
Energy Cost: {{totaleEnergetico}}
<hr>
Total: {{somma}}<br>
Integrated Cost:<br>
<hr>
Savings in euro:<br>
Savings %:<br>
<hr>
Safety equipment:
</div>
</div>
</div>
</div>