0

As soon as my application is launched, I access the IP address of the client and pass it on to the server. Based on the client IP the server will furnish some data.

Using this data I will decide how many child components should be embedded on the page, like using a ng-for loop.

My problem is, the server side call takes time to come back. By that time the ng-for loop is done with zero records.

How can I wait till the server call is returned and then initiate the "ng-for loop" ?

I tried using "EventEmitter" from the parent. I will emit an event on the parent component once the parent gets some value from the server. But the child components are not receiving the emitted event. Then I realized that, it's only working when child emits the event, the parent can catch it. Is this right ? Can the parent emit an event and can all the child components listen and catch it ?

Please advise.

Thanks Adam

Adam
  • 1,221
  • 4
  • 13
  • 27

1 Answers1

0

I think's you need to check if your data is not empty.

Try this:

<div *ngIf="myArray" *ngFor="let item of myArray">{{item | json}}</div>

When your variable myArray will be completed your ngFor working.

nevradub
  • 238
  • 1
  • 9