0
I am with the following code, it checks the value of _meditaTotal if it is greater than 70 the icone variable gets 'green', if it is lower q 70 and greater than 50 icone variable gets 'yellow' and if it is less than 50 icone variable gets 'red', but it is showing only red on the page.
public descritores;
public _mediaTotal: number;
public icone;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.descritores = navParams.get('anoSelecionado');
this._mediaTotal = this.descritores.icone;
if (this._mediaTotal > 70){
this.icone = 'verde';
}
else if (this._mediaTotal < 70){
this.icone = 'amarelo';
}
else (this._mediaTotal < 50)
this.icone = 'vermelho';
}
this.descritores.icone
is numerical type ?– GeekSilva
Yes, this.descripores.icone are of the numeric type, with two decimal places, example: 81.16.
– Leysson guimarães
Check if this.descripores.icone is even coming as numeric using console.log(typeof this.descripores.icone); . To make sure you are comparing numeric by using in if ( Number(this._mediaTotal) > 70) etc.
– André Vicente