Skip to content Skip to sidebar Skip to footer

How To Pass Value From Typescript Code To Css In Angular 6

I know I've to use ngClass or ngStyle but I'm not able to figure out how to pass that value. Here is my code. strip.component.ts import { ... } from '@angular/core'; @Component({

Solution 1:

Use class

<div [class]="'col-'+ widthValue"></div>

OR

Use style.width

<div [style.width]="(widthValue/12)*100 + '%'"></div>

DEMO

Post a Comment for "How To Pass Value From Typescript Code To Css In Angular 6"