If our component is not ready and waiting for data from server, then we can add loader using *ngIf.
Steps:
First declare a boolean:
loading: boolean = false;
Next, in your component add a lifecycle hook called ngOnInit
ngOnInit() {
this.loading = true;
}
and after you get complete dat...