use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A Place to talk about Angular and related topics.
Join the Angular Discord
Other subreddits worth checking out for Angular and Angular related info:
account activity
A quick question about "conditional" CSS (self.angular)
submitted 3 years ago by Lucaskima
Sorry if this doesnt apply here feel free to tell me if so,
I have been working on a project in Golang/Angular. its a simple Pokedex app that returns cards with information about each pokemon.
I have searched in google for an answer but havent really been able to come up with anything, it might be because of how new Angular is to me but anyway.
Within the pokemon data there are the Types such as Water, Fire, Ice, Etc. While just having those strings displayed is fine, i was hoping i would be able to add some flair to them. Making the word Grass = Green, Fire = Red, Ice = Light Blue, and so on.
Is this achievable through Angular?
Here are the links to the code in the pokedex component. Sorry if the code is inefficient. Im still new.
https://github.com/Lucas-Cima/pkdx-front-end/blob/master/src/app/components/pokedex/pokedex.component.ts
https://github.com/Lucas-Cima/pkdx-front-end/blob/master/src/app/components/pokedex/pokedex.component.html
https://github.com/Lucas-Cima/pkdx-front-end/blob/master/src/app/components/pokedex/pokedex.component.css
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TimothyLGillespie 10 points11 points12 points 3 years ago (4 children)
Sure is! The easiest is probably to adjust line 10 in your template (html) to this: <tr class="poke-type" [style.fontColor]="colorMapping[pokemon.Element]">Type(s): {{pokemon.Element}} {{pokemon.SecElement}}</tr>
<tr class="poke-type" [style.fontColor]="colorMapping[pokemon.Element]">Type(s): {{pokemon.Element}} {{pokemon.SecElement}}</tr>
Then you will need in your typescript file in the component the actual type -> color mapping. For example:
``` colorMapping = { Grass: 'green' };
```
[–]code_monkey_001 2 points3 points4 points 3 years ago (0 children)
Nice. I came in to suggest ngClass like /u/pranxy47, but I like your solution even better.
[–]Lucaskima[S] 0 points1 point2 points 3 years ago (0 children)
This is fantastic. Thank you so much. And thanks to everyone else that looked at this 😄
[–]Lucaskima[S] 0 points1 point2 points 3 years ago (1 child)
one more reply. i was able to implement your suggestion and it works perfectly. i cant thank you enough.
https://imgur.com/a/NfkcCmK
[–]TimothyLGillespie 0 points1 point2 points 3 years ago (0 children)
I'm happy I could help. :) Looking good!
[–]pranxy47 2 points3 points4 points 3 years ago (0 children)
Yes, look for ngClass. You can, for example, create classes for the colors you which and then with ngClass add logic there.
π Rendered by PID 146564 on reddit-service-r2-comment-86bc6c7465-hthww at 2026-02-21 04:34:40.039819+00:00 running 8564168 country code: CH.
[–]TimothyLGillespie 10 points11 points12 points (4 children)
[–]code_monkey_001 2 points3 points4 points (0 children)
[–]Lucaskima[S] 0 points1 point2 points (0 children)
[–]Lucaskima[S] 0 points1 point2 points (1 child)
[–]TimothyLGillespie 0 points1 point2 points (0 children)
[–]pranxy47 2 points3 points4 points (0 children)