I have data json content on numbers in percentage , those numbers are start 0.0 . I want to change color of those number if highs , lowers or in middle .
my pipe
@Pipe({
name: 'precntColors'
})
export class PrecntColorsPipe implements PipeTransform {
transform(value: any, args?: any): any {
let d = value
if (value >Math.round(0) && value<=Math.round(15)) {
d="green"
}
else if (value>Math.round(16) && value<=Math.round(49)) {
d="yellow"
}
else if (value>Math.round(50) && value <=Math.round(100)) {
d="red"
}
return d;
}
}
html
<div [ngClass]='myda.percentage.canceled |precntColors'>
</div>
When i run my app l got all number in green color ! and others colors are not showing . any ideas please ?
Aucun commentaire:
Enregistrer un commentaire