Ad
How To Check In Component.html If Column Type=1 Display Label Text Active Else Display Not Active?
I have object name ReportControl I face issue I cannot check value related to this object
if have column type 1 then display label active else display label not active on reportcomponent.html
data of object ReportControl as below
{"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);
}
reportcomponent.html
I need to check if column type = 1 then display label with text active else display label with text not active .
Expected result display label with text active
Ad
Answer
This is how you display text conditionally in html, Is this what you expect ?
<label>{{ReportControl.columnType == 1 ? 'Active' : 'Inactive'}}</label>
Using *ngIf
<label *ngIf="ReportControl.columnType == 1">Active</label>
<label *ngIf="ReportControl.columnType == 0">Inactive</label>
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad