猿问

如何签入组件.html如果列类型= 1显示标签文本活动否则显示不活动?

我有对象名称 报告控制 我遇到问题 我无法检查与此对象相关的值


如果列类型为 1,则显示标签处于活动状态,否则在报表组件上显示标签未处于活动状态.html


对象数据报告控制如下


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

on 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);


    }

报告组件.html


我需要检查列类型是否= 1,然后显示文本处于活动状态的标签,否则显示文本未处于活动状态的标签。


文本处于活动状态的预期结果显示标签


隔江千里
浏览 91回答 1
1回答

冉冉说

这就是你在html中有条件地显示文本的方式,这是你所期望的吗?<label>{{ReportControl.columnType == 1 ? 'Active' : 'Inactive'}}</label>用*ngIf<label *ngIf="ReportControl.columnType == 1">Active</label><label *ngIf="ReportControl.columnType == 0">Inactive</label>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答