0

I have an array of companies getting from a service and binding that array data with the help of *ngFor directive.

Now, I want to show a whole page covered 'waiting..' till the data gets bind to the mark up.

Till the time, I tried this

GetCompanies()
{
//here is 'startWaitingModal()'
this._svc.GetCompanies().subscribe(ret => {}, error => {}, () => { //here is 'endWaitingModal()'});
}

and I understand that endWaitingModal() called immediately after service call completion not after binding completion, which makes sense. After that I found this solution angular life cycle hook, It is working fine.

ngDoCheck()

this hook gets triggered whenever there is change in the the component markup. It helps me but this solution is not up to the mark as per my knowledge, because it is working like a parent listener (listening continuously) and will look for any change in the markup and gets triggered which is not a right way to do it. It should work like element specific, I think. Please guide me.

ElasticCode
  • 7,311
  • 2
  • 34
  • 45
musigh
  • 167
  • 1
  • 3
  • 13

0 Answers0