显示带有空消息的结果
答案 0 :(得分:0)
你可以这样做吗?
**Component.ts**
ngOnInit() {
this.searchResult = this.service.searchResult$.subscribe(cars => {
if(jsonEmptyCheck(car)) {
return [-1];
}
else {
this.alertService.showInfoAlert('content not available');
}
});
}
jsonEmptyCheck(jsonObject) {
if (jsonObject != null) {
if (Object.keys(jsonObject).length > 0) {
return true;
}
}
return false;
}
答案 1 :(得分:0)
ngOnInit() {
this.searchResult = this.service.searchResult$.subscribe(cars => {
this.searching = false;
this.rows = cars;
if (!cars || cars.length === 0) {
this.alertService.showInfoAlert('content not available');
}
);
}