【问题标题】:Passing arguments to css class in Angular在Angular中将参数传递给css类
【发布时间】:2021-09-10 13:46:32
【问题描述】:

如何将参数传递给 angular 中的 css 类?

.div-disabled[status="true"]
{
 pointer-events: none;
 opacity: 0.5;
 background: #CCC;
}

在我的 .ts 文件中,我有 disableDiv = true;

尝试了以下方法,似乎不起作用。

<div status="{{disableDiv}}" class="div-disabled"></div>

【问题讨论】:

    标签: javascript html css angular


    【解决方案1】:

    试试这个

    css 文件

    .div-disabled[status=true] {
        pointer-events: none;
        opacity: 0.5;
        background: #CCC;
    }
    

    html 文件

    <div [attr.status]="disableDiv" class="div-disabled"></div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-24
      • 2014-10-23
      相关资源
      最近更新 更多