title: Angular 6 get List of Objects in List Using a Key/Property
body: <p>The <strong>getEntities()</strong> method in <strong>Entity1Service.ts</strong> returns the following error.  </p>
  
  <p><code>Type 'Entity1' is not assignable to type 'Entity1[]'. Property 'includes' is missing in type 'Entity1'</code></p>
  
  <p>What is the correct way to get a list of objects that contain an id number associated to another entity? This application is using Angular 6.</p>
  
  <p><strong>Entity1.ts</strong></p>
  
  <pre><code>export class Entity1 {
      id: number;
      name: string;
      entitiy2Id: number;
  
      constructor(
          _id: number,
          _name: string,
          _entity2Id: number
      ) {
          this.id = _id,
          this.name = _name
          this.entity2Id = _entity2Id
      }
  }
  </code></pre>
  
  <p><strong>Entity2.ts</strong></p>
  
  <pre><code>export class Entity2 {
      id: number;
      name: string;
  
      constructor(
          _id: number,
          _name: string
      ) {
          this.id = _id;
          this.name = _name;
      }
  }
  </code></pre>
  
  <p><strong>Entity1Service.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Entity1 } from './models/entity1';
  
  @Injectable({
    providedIn: 'root'
  })
  export class Entity1Service {
  
    entities: Enity1[] = [
      { 
        id: 1,
        name: 'First',
        entity2Id: 1 
      },
      { 
        id: 2,
        name: 'Second',
        entity2Id: 1 
      },
      { 
        id: 3,
        name: 'Third',
        entity2Id: 1 
      }
    ];
  
    constructor() { }
  
    getEntities(_entity2Id: number): Entity1[] {
      // The following line does not work
      return this.entities.find(entity =&gt; entity.entity2Id === _entity2Id);
    }
  
  }
  </code></pre>