Home > OS >  how can I pass a typescript color variable to an html div?
how can I pass a typescript color variable to an html div?

Time:08-25

does anyone know how can I pass a typescript color variable to an html div? i am also using scss

.ts

{colorBorder}

.scss

.colorBorder{
    border: 5px var(--colorBorder);
}

.html

<div >

CodePudding user response:

You can use ngStyle or set the particular style like [style.border] like so.

<p [ngStyle]="{ border: '1px solid '   borderColor }">
  Start editing to see some magic happen :)
</p>

or

<p [style.border]="'1px solid '   borderColor">
    Start editing to see some magic happen :)
</p>

stackblitz

  • Related