简体   繁体   中英

How to call complete method on nodejs api call

Tried to show loading image on nodejs api call but not working,Getting some error like below. How to show loading image on data receiving time and how to hide loading image on after complete the data received.Anyone know please help.

Error:

error TS2345: Argument of type '(com: any) => void' is not assignable to parameter of type '() => void'.

getProductsData(collection) { 
          this.userService.gettableData(collection).subscribe(
          res => {
            this.loader=true;
            this.getDetails = res; 
          },
          err => {
            console.log(err); 
          },
          com => { 
             alert("Data got it..Completed!!!!"); 
             this.loader=false; 
          }
        ); 
      }

in your html add loader condition as below:

<div *ngIf="loader"> <div>Loading...</div> </div>

if the loader variable is true it displayed your spinner else otherwise!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM