显示空消息的结果

时间:2017-09-08 12:02:37

标签: angular

显示带有空消息的结果

2 个答案:

答案 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');
        }
    );
}