小编S. *_*son的帖子

如何在Angular组件的样式标签中使用字符串插值?

@Component({
  selector: 'app-style',
  template: `
    <style>
      .test {
        color: {{ textColor }}
      }
    </style>
  `
})
export class StyleComponent {
  textColor = "red";
}
Run Code Online (Sandbox Code Playgroud)

这似乎不起作用,我需要我的样式是动态的,并在一些特定的CSS类.还有其他方法可以做到这一点吗?

css string interpolation styles angular

8
推荐指数
3
解决办法
4951
查看次数

标签 统计

angular ×1

css ×1

interpolation ×1

string ×1

styles ×1