title: Typescript/Angular 2 - filter out objects that do not include a specific string property
body: <p>I'm creating a filter in my angular application that removes all objects that do not contain specific string property within a nested array.</p>
  
  <p>for example... I have an array that looks like this:</p>
  
  <p><strong>JSON:</strong></p>
  
  <pre><code>[
    {
      "id":1,
      "name":"example1",
      "categories": [
        "red",
        "yellow",
        "pink",
        "green"
      ]
    },
    {
      "id":2,
      "name":"example2",
      "categories": [
        "blue",
        "black",
        "purple",
        "green"
      ]
    },
    {
      "id":3,
      "name":"example3",
      "categories": [
        "red",
        "yellow",
        "black",
        "white"
      ]
    }
  ]
  </code></pre>
  
  <p>When you click a button the function will only show the objects that contain the specified category.</p>
  
  <p><strong>Something like...</strong></p>
  
  <pre><code>&lt;button (click)="filter('red')"&gt;filter by category&lt;/button&gt;
  
  filter(category) {
    // only show objects that contain (category) string.
  }
  </code></pre>
  
  <p>Any help would be great cus I just haven't managed to crack it.</p>
  
  <p>Hope this is enough info</p>