How to stop progress dialog when response is came from server


#1

i created function in that i have progress dialog coding but problem is how to stop it when response is came.
Code that i used

presentLoading() {
        let loading = Loading.create({
          content: "Please wait...",
          duration: 3000
      });
        this.navController.present(loading);
  }

#2

there is a function you can call to dismiss loading.

When your response is here then you can call loading.dismiss() and it will be dismissed


#3

thankx piyukore…
i will try your suggestion. but the problem is that i declare var loading global then i get error loading can not find. code that i used

export class EnquiryPage {

  slideOneForm: ControlGroup;
  
  firmName: AbstractControl;
  firstName: AbstractControl;
  lastName: AbstractControl;
  mobileno: AbstractControl;
  refmobileno: AbstractControl;
  city: AbstractControl;
  emailid: AbstractControl;
  mtype: AbstractControl;
  public loading: any;

  mobilenoChanged: boolean = false;
  firmNameChanged: boolean = false;
  firstNameChanged: boolean = false;
  lastNameChanged: boolean = false;
  
  items: Array<{ value: number, text: string, checked: boolean }> = [];
  
  submitAttempt: boolean = false;

  constructor(private navController: NavController,private formBuilder: FormBuilder,private enquiry: WebService) {

    this.items.push({ value: 1, text: 'Super Distributor', checked: false });
    this.items.push({ value: 2, text: 'Distributor', checked: false });
    this.items.push({ value: 3, text: 'Retailer', checked: false });
    this.items.push({ value: 4, text: 'End User', checked: false });

      this.slideOneForm = formBuilder.group({
        'firmName': ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z0-9 ]*'), Validators.required])],
        'firstName': ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
        'lastName': ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
        'mobileno': ['',Validators.compose([Validators.minLength(10),Validators.maxLength(10), Validators.pattern('[0-9 ]*'),Validators.required])],
        'refmobileno': ['',Validators.compose([Validators.minLength(10),Validators.maxLength(10),Validators.pattern('[0-9 ]*')])],
        'city': ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
        'emailid': ['',Validators.compose([Validators.minLength(10),Validators.maxLength(100),ValidationService.emailValidator])],
        'mtype': ['',Validators.required]
      });

    this.firmName = this.slideOneForm.controls['firmName'];
    this.firstName = this.slideOneForm.controls['firstName'];
    this.lastName = this.slideOneForm.controls['lastName'];
    this.mobileno = this.slideOneForm.controls['mobileno'];
    this.refmobileno = this.slideOneForm.controls['refmobileno'];
    this.emailid = this.slideOneForm.controls['emailid'];
    this.city = this.slideOneForm.controls['city'];
    this.mtype = this.slideOneForm.controls['mtype']; } 

    elementChanged(input){
      let field = input.inputControl.name;
      this[field + "Changed"] = true;
    }

      save(){ 
        if(this.slideOneForm.valid) {
            this.getEnquiry();
            this.presentLoading();
            //this.doAlert(this.username.value);
        }
    }   
    getEnquiry() {

          this.enquiry.getEnquiryDetails(this.mtype.value,this.firmName.value,this.firstName.value,this.lastName.value,this.mobileno.value,this.refmobileno.value,this.emailid.value,this.city.value).subscribe(
              data => {

              this.loading.dismiss();
              this.doAlert(data.toString());
              //var resString = data;
              //resString = resString.substring(resString.indexOf("{"), resString.indexOf("}") + 2);
              
              //ata.json();
              },
              err => console.error(err),
              () => console.log('getRepos completed')
          );
      }
      presentLoading() {
      this.loading = Loading.create({
          content: "Please wait..."
      });
        this.navController.present(loading);
      }
     doAlert(msg: string) {
      let alert = Alert.create({
        title: 'Welcome',
        subTitle: msg,
        buttons: ['OK']
      });
      this.navController.present(alert);
    }
}

#4

solved my issue…thank you piyukore;