title: Angular: cannot read property of undefined but still displays data
body: <p>I'm quite confused because my application is displaying necessary data, but there are still errors in the console that I would like to get rid of.</p>
  
  <p>Typescript:</p>
  
  <pre><code>  activeClient: Client;
  
    constructor(private clientService: ClientService) { }
  
    ngOnInit() {
      this.inViewMode = true;
      this.clientId = parseInt(window.location.pathname.split('/')[2], 10);
      this.clientService.getClientById(this.clientId)
          .subscribe(data =&gt; this.activeClient = data);
    }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="form-row"&gt;
     &lt;div class="form-group col-12"&gt;
         &lt;label for="name"&gt;Ettevõtte nimi&lt;span *ngIf="!inViewMode" class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
         &lt;input class="form-control" id="name" [value]="activeClient.companyName"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Client model:</p>
  
  <pre><code>export interface Client {
      id?: number;
      companyName?: String;
      firmRegNo?: number;
      address?: String;
      clientName?: String;
      phoneOne?: number;
      phoneTwo?: number;
      email?: String;
      explanation?: String;
      rating?: number;
      status?: String;
      clientContract?: ClientContract;
  }
  </code></pre>