Exercise: The Built-in `NgStyle` Directive
Let's Practice working with an `NgStyle` directive.
We'll cover the following
Let’s do some coding!
Objectives
For this task, let’s imagine a component with three range pickers using standard HTML input components. The pickers allow us to choose a value from 0
to 255
. Each picker represents a single color value in the RGB system. So, the first picker selects a value for red
, the second one for green
, and the last one for blue
.
These are the requirements for this task:
-
Next to each input, there’s an empty div element. Make the background color represent the selected color on that picker. So, if the selected value is
0
, then the button should beblack
, and when it’s 255, it should bered
. Any value in between should match that RGB value, for instance:- Value =
100
, results inrgb (100,0,0)
- Value =
200
, results inrgb (200,0,0)
- Value =
-
Underneath all inputs, there is an empty
div
. Please set its background to a color value based on all three properties.
Task
Please write the code below:
Get hands-on with 1400+ tech skills courses.