I've tried some stuff cause I am building a weather dashboard.
I load weather data with http and subscribe, so I'll getting an observable back I cannot go trough like an array in typescript to add new properties.
For example I want to look on each weather data and look if a value has more than 70 °F and tell the weatherdata item to add a new property "weatherdata-sun-hot". Otherwise it should use an other class name "weatherdata-sun-normal" I would use this as a class name to put it in html later with interpolation.
So my idea is to solve this with the html template
So far I do have my code here
<ul>
<li *ngFor="let item of weatherdata">{{item.dt_txt}} | {{item.main.temp_min}} -> {{item.main.temp_max}}</li>
</ul>
Is there an elegant way to solve this?
Thanks for any help.
<li *ngFor="let item of weatherdata" [ngClass]="[item.main.temp_max > 17 ? 'weather-sun-hot' : 'weather-sun-normal']" >{{item.dt_txt}} | {{item.main.temp_min}} -> {{item.main.temp_max}}</li>But for me it's looking like ugly code. Or would you implement it the same way? I am confused.