popup is not closing using ngx bootstrap in Angular 4

1,190 views
Skip to first unread message

Jasthi Rajendhra

unread,
Aug 11, 2017, 7:40:23 AM8/11/17
to Angular and AngularJS discussion
when ever i search any locations using zip code from UI, iam using popup to show the user that backend search process is going on.For this i created one service to open and close popup.before search service searches locations, iam able to create popup. how ever when search is completed popup is not closing.Below is the code which iam using

import { Injectable,Component,OnInit,ViewChild, ElementRef,TemplateRef  } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class';

@Injectable()
export class **LoadingIndicatorService** {

  bsModalRef: BsModalRef;  
  public config = {
       animated: true,
       keyboard: false,
       backdrop: "static",       
       ignoreBackdropClick: false
  };
  constructor(private modalService: BsModalService) { 
  }

  public openLoadingIndicator() {          
    this.bsModalRef = this.modalService.show(**LoadingIndicatorComponent**,Object.assign({}, this.config, {class: 'modal-sm'}));               
  }

  public closeLoadingIndicator(){
    this.bsModalRef.hide();
  }  

}

@Component({
  selector: 'loading-indicator-content',
  templateUrl: './loading-indicator.html',
  styleUrls: ['./loading-indicator.css']
})
export class **LoadingIndicatorComponent** implements OnInit{     
  ngOnInit() { }          
  constructor( private bsModalRef: BsModalRef,private modalService: BsModalService,private loadingIndicatorService: LoadingIndicatorService) {  
  }     
}

Iam calling **LoadingIndicatorService** from **SerachLocations Component**.When usee put any location in search box pop up comes and popup should close once search is completed but it is not happening.

SerachLocations Component{

 some method(){
 LoadingIndicatorService.openLoadingIndicator();//popup is opening fine here
 //serach locations service will be called here
 LoadingIndicatorService.closeLoadingIndicator();//popup should hide when search is done but it is not closing
 }
}
Reply all
Reply to author
Forward
0 new messages