Skip to content

Instantly share code, notes, and snippets.

@riapacheco
Created July 20, 2022 18:06
Show Gist options
  • Save riapacheco/481301325ac09224043407de16d0110e to your computer and use it in GitHub Desktop.
Save riapacheco/481301325ac09224043407de16d0110e to your computer and use it in GitHub Desktop.
Conditional [ngStyle]: Add multiple properties / values in ternary operator
<div [ngStyle]="isMobile ? {'font-size': '0.8rem'} : {'font-size': '1rem'} ">
This is a div
</div>
<div [ngStyle]="isMobile ? { 'margin-right': '10px',
'font-size': '2rem',
'margin-top': '5rem'
} : { 'margin-right': '0px',
'font-size': '1rem'} ">
This is a div
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment