Issue
So i have an Array it names getFileAnalyze and looks like this:
getFileAnalyze:[ fileCatagory:"...", date:"...", content="..."]
My task is to show the date and the content on the Webside and make each date and content colored in connect with from which fileCatagory they are.
e.g. all dates and contents from fileCatagory "technical" should have the font color blue.
So i don't know how can i implement a function for this in angular with typescript .. :/
Can anyone help me ??
Solution
Use a style in the html template reading from a dictionary of colors. You can do something like this in html
<div *ngFor=“let file of getFileAnalyze”
[style.background-color]=“colors[file.fileCatagory]”
>
{{file.contents}}
</div>
And this in component TS
colors: {[category:string]: string} = {categoryName1: “blue”, cat2:”#ccc”}
Answered By - bjlasc01
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.