last day (359 days later) » 

10:45 AM
Hello Welcome to All Angular Newbies
room topic changed to Angular Newbies: This chat is for Angular Newbies who just started with Angular. You can ask any question and start discussion related to Angular. [angular] [typescript]
welcome @Monis
 
Thanks
 
11:03 AM
welcome @AkilMakda
 
hello
 
Hello @AchyuthKodali
 
i got an issue in angular
 
What is the issue?
 
i have a set of colors( aprox 20 ) i have an API that will send different buzzwords ... i have to set a random color to each buzzword.... that color should not change when the user is in the session...
note: my buzzwords will update frequentlu..
ex: if a buzzword named "india" have red color setted.. then no other buzzword could have red color..
 
11:18 AM
What will happen if there are more buzzwords than the set of colors? For example buzzword will be more than 20 then what color should it have?
 
i have 30 colors defined...
My API will not send more than 20 buzzwords...
 
Oh okay
 
but it will send them in randomly in the set of 5
setColors(){
for(let i = 0; i < this.buzzwordData.length; i++){
this.buzzwordData[i]["fColor"] = this.domSanitizer.bypassSecurityTrustStyle(Colors[i][1]);
this.buzzwordData[i]["tColor"] = this.domSanitizer.bypassSecurityTrustStyle(Colors[i][0]);
this.buzzwordData[i]["dtColor"] = Colors[i][0];
}
}
i use this currently.....
ignore tcolor fcolor... imagine them as single color
 
What you can do is.
Create a list of colors with a boolean isApplied with each item in array. Like this:
```
const colors = [
{
color: 'red',
isApplied: false
},
{
color: 'blue',
isApplied: false
}
]
Then whenever a color in the list is applied to any buzzword you can make isApplied of that color to true.
and next time if the same color is selected by random number it should not apply it because it is alraedy applied
You should initialize color arrays when a new session starts.
 
hmm... it makes sense... i'll try this..
 
11:25 AM
(y)
 

  last day (359 days later) »