title: Wait for Service Api call to complete in Angular 8
body: <p>I am trying my first Angular 8 Crud Web app and wrote a page to list some company names from WebApi</p>
  
  <p>My Service is correctly getting data and Iam able to print it on console</p>
  
  <pre><code>//Service.ts
  export class CompanyService {
    allCompanys: Company[]
    constructor(private httpClient: HttpClient) { }
    // Returns all the companys
    GetAll(): Company[] {
  
      this.httpClient.get&lt;Company[]&gt;('https://localhost:565656/api/company').subscribe(result =&gt; {
        this.allCompanys = result;
  
        //Shows data Sucessfully from Server :Working fine
        console.log(this.allCompanys);
  
      }, error =&gt; console.error(error));
  
      return this.allCompanys;
    }
  </code></pre>
  
  <p>But in my component I try to get the data at the starting of page by calling the service and assign it to local varaible it is giving undefined  </p>
  
  <pre><code>     ///Component.ts
  
        export class CompanyListComponent implements OnInit {
        Companylist: Company[] 
   constructor(private route: ActivatedRoute, private router: Router, private companyService: CompanyService) {  }
          ngOnInit() {
  
            this.Companylist = this.companyService.GetAll();  
            //This is executing before the service call is returning and returning Undefined
            console.log("At Component " + this.Companylist)
  
          }
  </code></pre>
  
  <p>My html look likes below and table not showing</p>
  
  <pre><code>  //html
  
        &lt;tr *ngFor="let company of Companylist"&gt;
        &lt;td&gt;{{company.Name}}&lt;/td&gt;
        &lt;td&gt;{{company.Phone}}&lt;/td&gt;
        &lt;td&gt;{{company.Email}}&lt;/td&gt;
        &lt;td&gt;{{company.Address}}&lt;/td&gt;
         &lt; /tr&gt;
  </code></pre>
  
  <p>I tried Observables also but not working.I need the variable to bind after the api is called.Can somebody advice what I am doing wrong </p>
  
  <p>I had already checked the similar cases in SO and cant find something similar(may be not understanding to me)</p>