Bird
0
0

Given the component variables:

medium📝 component behavior Q4 of 15
Angular - Directives
Given the component variables:
textColor = 'purple';
isItalic = true;

What styles will be applied by this template?
<div [ngStyle]="{'color': textColor, 'font-style': isItalic ? 'italic' : 'normal'}">Sample</div>
AText color purple and font style normal
BText color purple and font style italic
CText color default and font style italic
DText color default and font style normal
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate color

    The variable textColor is 'purple', so color will be purple.
  2. Step 2: Evaluate font-style

    isItalic is true, so font-style will be 'italic'.
  3. Final Answer:

    Text color purple and font style italic -> Option B
  4. Quick Check:

    Conditional operator sets font-style correctly. [OK]
Quick Trick: Ternary sets style based on boolean [OK]
Common Mistakes:
  • Ignoring the ternary condition
  • Assuming default styles override ngStyle
  • Confusing font-style with font-weight

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes