如果列类型= 1显示标签文本,则如何检入component.html,否则显示非活动?

问题描述 投票:0回答:1

我有对象名称ReportControl,我遇到问题,我无法检查与此对象相关的值

如果列类型为1,则显示标签处于活动状态,否则显示标签在reportcomponent.html上处于非活动状态

对象ReportControl的数据如下

{"reportId":2028,"fieldName":"offilneURL","reportStatus":"HiddenColumn","columnType":1}

关于reportcomponent.ts

this._displayreport.GetReportControl(param2).subscribe((res: any) => {
        this.ReportControl = res;
        console.log("report control is" + JSON.stringify(this.ReportControl) );

      });

on service.ts

  GetReportControl(id : string){
      return this.http.get<any[]>(this.url+ 'report/GetAllReportControl/id=' + id)
      .map(res=>res);

    }

reportcomponent.html

我需要检查列类型是否为1,然后显示带有活动文本的标签否则显示标签的文本无效。

带有文本的预期结果显示标签

javascript typescript angular7 angular-directive angular-components
1个回答
0
投票
使用*ngIf

<label *ngIf="ReportControl.columnType == 1">Active</label> <label *ngIf="ReportControl.columnType == 0">Inactive</label>

© www.soinside.com 2019 - 2024. All rights reserved.