Issue
Trying to display the message when the searchResult is empty. But not getting the desired result. Here is my component and service file.
Component.ts
ngOnInit() {
this.searchResult = this.service.searchResult$.subscribe(cars => {
this.searching = false;
this.rows = cars;
if(cars.length === 0) {
return [-1];
}
else {
this.alertService.showInfoAlert('content not available');
}
});
}
service.ts
showInfoAlert(msg: string) {
this.showAlert(true, msg, 'alert-container');
}
Solution
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');
}
);
}
Answered By - Alexander
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.