【问题标题】:dynamic css class on a span element - angular 7跨度元素上的动态 CSS 类 - 角度 7
【发布时间】:2020-09-14 04:35:31
【问题描述】:

我在 ngx 数据表中有一个 span 元素。我想根据值动态更改css类。

这是我的 html 代码:

<ngx-datatable #orderinvoice class="bootstrap" [rows]="invoiceSource" [headerHeight]="50" [footerHeight]="50"
            [rowHeight]="'45'" [scrollbarH]="true" [columnMode]="'force'" [limit]="limit"
            [sorts]="[{prop: 'sNo', dir: 'asc'}]">
            <ngx-datatable-column *ngFor="let column of displayColumns" [name]="column.name">
                <ng-template let-column="column" ngx-datatable-header-template>
                    <span>{{column.name}}</span>
                </ng-template>
                <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-value="value" let-row="row">
                    <span [ngClass]="{'label label-primary': row[column.value] === 'Complete', 'label label-warning':row[column.value] === 'Processing' }"
                    *ngIf="column.name !== 'Actions'">{{row[column.value]}}</span>
                    <span *ngIf="column.name === 'Actions'">
                        <button class="btn btn-success mr-1 btn-fab" placement="top"
                            data-controls-modal="custom-modal-2" data-toggle="modal" data-backdrop="static"
                            data-keyboard="false" ngbTooltip="View" (click)="SerachInvoice(row , 'custom-modal-2')">
                            <i class="ft-eye"></i>
                        </button>
                        <button class="btn btn-primary mr-1 btn-fab" placement="top" ngbTooltip="Edit"
                        [disabled]="financeYear"   (click)="edit(row)">
                            <i class="ft-edit"></i>
                        </button>
                        <button class="btn btn-warning mr-1 btn-fab" placement="top" ngbTooltip="Print"
                            (click)="SerachInvoice(row,'printSection')">
                            <i class="fa fa-paper-plane-o"></i>
                        </button>
                    </span>
                </ng-template>
            </ngx-datatable-column>
        </ngx-datatable>

在上面我需要根据条件申请类

 <span [ngClass]="{'label label-primary': row[column.value] === 'Complete', 'label label-warning': row[column.value] === 'Processing' }"

听说上课成绩无法得到,请问是什么原因??

下面是引导类

【问题讨论】:

  • 听到类无法加载
  • 你现在能看到 Alex Biro
  • 抱歉,可能是我的问题,但在这种情况下,我还是不明白 hear 这个词。尝试从控制台复制错误,或截屏。
  • 你的元素应用了哪些css类?没有?或者它们是否被应用和覆盖
  • 你能分享你的表格html代码吗?

标签: html css angular ng-class


【解决方案1】:

【讨论】:

  • 是的,它的工作 supun De silva 但所有行数据都以粗体文本显示......我不想那样显示......
  • 使用如下类删除字体粗细.fw-default { font-weight: inherit !important; } .fw-default { font-weight: unset !important; } 新示例stackblitz.com/edit/angular-ivy-2se6yv
  • 一切都很完美..但问题是使用的css字体样式与其他网格页面不同..你能建议所有页面都一样吗..我怎么能克服这个?
  • 在 css 类中设置 font-weight: 400 !important; 而不是 font-weight: inherit !important; 看看是否有帮助
  • 抱歉打断了上面的屏幕是差异你能不能看看我改变了你所说的css但没有差异..
猜你喜欢
  • 2019-01-07
  • 1970-01-01
  • 2019-04-23
  • 1970-01-01
  • 1970-01-01
  • 2013-11-05
  • 1970-01-01
  • 2017-10-21
  • 1970-01-01
相关资源
最近更新 更多