title: Angular 2 - Remove element from object array according to one of its properties
body: <p>I'm trying to Remove an element from object array according to one of its properties, in Angular 2.</p>
  
  <p>How can I implement the <code>removeItem</code> function so it will remove the <code>comment</code> object from the array <strong>according to its id property</strong> and thus remove it from the list ?</p>
  
  <p>Here's the HTML template (loops with <code>ngFor</code> for all comments):</p>
  
  <pre><code>&lt;div *ngFor="let comment of list"&gt;
       &lt;button (click)="removeItem({{comment.id}})"&gt;delete&lt;/button&gt;
       (... comment.... )
       ....
  </code></pre>
  
  <p>Here the Angular 2 code:</p>
  
  <pre><code>export class Comments {
  
      list =
          [new Comment(1, "text one", "koby", new Date("2015.01.02")),
           new Comment(2, "text two", "adim", new Date("2017.02.02")),
           new Comment(6, "text six", "asaf", new Date("2016.11.04"))
          ];
  
      addItem(val: string) {
          this.list.push(new Comment(3, "kokoko", "kobydo", new Date("2015.01.02")));
      }
      removeItem(id: number) {
          // How do I remove it from the array ?
      }
  }
  
  export class Comment {
  
      constructor(
          public id: number,
          public text: string,
          public creator: string,
          public date: Date
      ) { }
  
  }
  </code></pre>