Angular - Directives
Why does this code cause an error?
color = 'blue';
<div [ngStyle]="{color}">Text</div>
color = 'blue';
<div [ngStyle]="{color}">Text</div>
Angular requires keys in the ngStyle object to be strings, so keys must be quoted.
The key color is unquoted, causing a syntax error.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions