[英]interpolation to a css class in an external file angular 2
I'm wondering if is possible to pass a variable to a css class into an external css file in angular 2, like from: 我想知道是否可以将变量传递给css类到角度为2的外部css文件,如:
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 然后在“app.component.css”我想通过
.mydiv{ background: {{bgc}}; }
Is this possible? 这可能吗?
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: 如果您需要以编程方式更改样式,我建议您在以下链接中查看ngStyle:
https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.