angular-randomcolor
Simple library where you can generate random colors.
Installation
- In order to install it you need to run
npm i angular-randomcolor --save
- Add it to your
app.module
; imports:
NOTE
Yo do not have to import the RandomcolorModule if you are using the library just for generating the color in your .ts
(see Usage 1)
Usage 1
Generate a random hexadecimal color is simple:
;...
Usage 2
You can randomize your text and/or background color directly in your HTML:
bgColor
will randomize your background color. (optional)textColor
will randomize your text color. (optional)
You can pass an empty array so the color will be generate randomly or you can use your own color array so it will pick one of those randomly.