Thuta Learning
ရှာဖွေရန်
IntermediateWeb Developmentintermediate

Attribute: ngStyle

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ngStyle directive သည် element တစ်ခုတွင် inline styles များကို dynamically set လုပ်ရန် အသုံးပြုသည်။

typescript
<div [ngStyle]="{
  'background-color': bgColor,
  'font-size': fontSize + 'px',
  'font-weight': isBold ? 'bold' : 'normal',
  'padding': '20px'
}">
  Styled Content
</div>

// component.ts
export class MyComponent {
  bgColor = '#3498db';
  fontSize = 18;
  isBold = true;
}
You should see
(Div သည် blue background, 18px font size, နှင့် bold font weight ဖြင့် ပေါ်လာမည်)
Attribute: ngStyle | Thuta Learning