I want to make a simple thing that the user input a color that he choose and make the color begin on some paragraph .
The input and the click button that the user send the inputColor to the typescript :
<form>
<input #inputColor type="text"/>
<button type="button" (click)="changeColorText(inputColor)"></button>
</form>
The function changeColorText() on the typescript :
export class HelloWorld implements OnInit {
public inputColor:string;
constructor() { }
ngOnInit(): void {
}
public changeColorText(str:string) :void {
this.inputColor = str;
}
}
The problem :
The paragraph change the color if i choose one (Witout input from the user) :
<p style="color:blue">Hello World !</p>
But I want what the user put in the box to make the paragraph like the color that sent, I couldn't find the correct syntax here:
<p style="color:{{inputColor}}">Hello World !</p> // ERROR !!!!
<p style=`color:{{inputColor}}`>Hello World !</p> // No compilation error .. but not working:
public inputColor:string='';(click)="changeColorText(inputColor)"andinputColoris not a string but anHTMLElement?