1

I'm wondering if is possible to pass a variable to a css class into an external css file in angular 2, like from:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app works!';
  bgc: string = 'orange'
}

then on the "app.component.css" I would like to pass like

.mydiv{ background: {{bgc}};  }

Is this possible?

PhoneixS
  • 10,574
  • 6
  • 57
  • 73
jcdsr
  • 1,123
  • 1
  • 17
  • 35

1 Answers1

0

I don't think this would be possible.

If you need a style to change programmatically, I would suggest looking into ngStyle at the link below:

https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html

chrispy
  • 3,552
  • 1
  • 11
  • 19