我在使用angular 7应用程序时遇到问题,我需要检查
如果在component.html上使用* ngIf,则ReportControl对象上是否存在Reportid。
在report.component.ts上
displayreport:any={};
Reportid: string;
ngOnInit() {
const paramIndex = window.location.href.indexOf('id=');
if (paramIndex > 0) {
let param = window.location.href.substring(paramIndex);
let param1 = param.split('&')[0];
let param2 = param.substr(param.indexOf('=') + 1);
this.Reportid=param2;
}
}
this._displayreport.GetReportControl(Reportid).subscribe((res: any) => {
this.ReportControl = res;
console.log("report control is" + JSON.stringify(this.ReportControl) );
});
this.ReportControl只返回一个对象:
{"reportid":"2040","reportName":"financialAsset","reportType":"1"}
在report.component.html上
如何检查ReportControl是否具有Reportid?