title: ERROR TypeError: Cannot read property 'ID' of undefined (Angular 8)
body: <p>Am always getting this error 'Cannot read property 'ID' of undefined' in my html code. But my the data from the api is perfectly loading, what do i do to resolve this error.(Angular 8)</p>
  
  <p>I think this is occurring  because my data is not getting loaded instantly and it is taking time, but eventually it is getting loaded. The error is showing in this line '*ngIf="!systemCheck &amp;&amp; systemCheck &amp;&amp; !canEdit"</p>
  
  <pre><code>&lt;span *ngIf="!systemCheck &amp;&amp; systemCheck &amp;&amp; !canEdit"&gt;
                &lt;button class="btn btn-primary" type="submit"&gt;
                  Save
                &lt;/button&gt;
              &lt;/span&gt;
  
  
  this.stakeholderService.getVendorStatus(this.statusID).subscribe(
        result =&gt; {
          console.log(result);
          if(!result){
            this.flag = false;
          }
          else {
            this.flag = true;
  
          let userRole = localStorage.getItem('role');
          if (userRole == AppConstants.SUPERADMIN_ROLE_NAME) {
            this.canEdit = true;
          }
          else {
            this.canEdit = false;
          }
          this.modelVendorStatus = result;
  
          this.color = result.colourCode;
  
          if (this.color != null &amp;&amp; this.color != "" &amp;&amp; this.color != undefined) {
            this.showBox = true;
          }
  
          this.systemCheck = result.isSystem;
  
          if(this.modelVendorStatus) {
  
          this.vendorStatusForm.patchValue({
            entityType: result.entityType,
            description: result.description,
            isDefault: result.isDefault,
            isSystem: result.isSystem,
            colourCode: result.colourCode,
            sortOrder: result.sortOrder,
            title: result.title,
          });
        }
        }
      },
        error =&gt; {
          this.errorMessage = error;
          if (error.status === 401)
            this.router.navigate(["/logout"]);
        });
  
  </code></pre>
  
  <p>The error goes like this</p>
  
  <pre><code>VendorStatusEditComponent.html:115 ERROR TypeError: Cannot read property 'ID' of undefined
      at Object.eval [as updateDirectives] (VM66404 VendorStatusEditComponent.ngfactory.js:555)
      at Object.debugUpdateDirectives [as updateDirectives] (core.js:39364)
      at checkAndUpdateView (core.js:38376)
      at callViewAction (core.js:38742)
      at execComponentViewsAction (core.js:38670)
      at checkAndUpdateView (core.js:38383)
      at callWithDebugContext (core.js:39716)
      at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:39299)
      at ViewRef_.detectChanges (core.js:27092)
      at ApplicationRef.tick (core.js:35380)
  
  </code></pre>
  
  <p>part where that I missed, sorry for that</p>
  
  <pre><code>&lt;div *ngIf="modelVendorStatus.ID &gt; 0"&gt;
        &lt;div&gt;
          &lt;hr/&gt;
        &lt;/div&gt;
        &lt;app-record-info [record]=modelVendorStatus&gt;&lt;/app-record-info&gt;
      &lt;/div&gt;
  
  </code></pre>