Quantcast
Channel: Conditionally style text in Angular2 - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Conditionally style text in Angular2

$
0
0

I have a list of object like this {name : 'Susan', number : 1}. I need to show the name colored depending on the number (if the number is 1 the name has to be red, if 2 blue, if 3 green and if 4 orange).In the template I have:

<p *ngFor="let item of data">    {{item.name}}</p>

How can I achive this?


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>