Promises in angular are used to make programming / flow to work in synchronous way.

When you want to hold executions till you get response from some API or method

Below code demonstrates implementation of promise in angular app


 

  Submit(){
    this.GetDataFromAPI().then((data)=>{
        /// Some Code
    },(error)=>{
        /// Some Code
    })
  }


  GetDataFromAPI() {
    return new Promise<boolean>((resolve, reject) => {      
      this.service.GetDataFromAPI().subscribe((data: any) => {
        resolve(data);
      }, ((error) => {
        reject(error);
      }));
    })
  }

 

In above code Submit function will wait until completion of GetDataFromAPI.